[Plugin: More Types] Warning: in_array() expects parameter 2 to be array
-
With the more types plugin i have a problem with a warning message from php
When i openup the more types plugin and try to create or modify a custom posttype i get the following error:
Warning: in_array() expects parameter 2 to be array, string given in wp-content/plugins/more-types/more-types-settings.php on line 291
The easiest way to solve this, is by editing more-types-settings.php and go to this part around line 291
$tax = array(); $stax = array(); $mytax[] = $more_types_settings->get_val('taxonomies'); foreach($wp_taxonomies as $taxonomy) { if (!trim($taxonomy->label)) continue; $tax[$taxonomy->name] = $taxonomy->label; if (in_array($taxonomy->name, $mytax)) $stax[] = $taxonomy; }
at line:
if (in_array($taxonomy->name, $mytax)) $stax[] = $taxonomy;
it fails
in_array($taxonomy->name, $mytax)
$mytax is not an array but code says it is (see the []):
$mytax[] = $more_types_settings->get_val('taxonomies');
However, some php configurations do not understand that for a unknown reason, i think.So the easiest way is to add up:
$mytax = array();
above
$mytax[] = $more_types_settings->get_val('taxonomies');
so we get:$tax = array(); $stax = array(); $mytax = array(); $mytax[] = $more_types_settings->get_val('taxonomies'); foreach($wp_taxonomies as $taxonomy) { if (!trim($taxonomy->label)) continue; $tax[$taxonomy->name] = $taxonomy->label; if (in_array($taxonomy->name, $mytax)) $stax[] = $taxonomy; }
It is a easy and quick fix, but when more types gets updated, the $mytax array will not be present and will probally cause the same warning message.
Could this simple fix be added in the upcoming release?
An another fix is probally, but is not tested by adding up
$mytax = array();
in the functions.php of your theme, with that setting it is possible the error disappears too and you can update more types without problems.Request is to add up that line in de next release, is that possible?
This problem has been appeared by two WordPress installations which are managed by me.
- The topic ‘[Plugin: More Types] Warning: in_array() expects parameter 2 to be array’ is closed to new replies.