WordPress.org

Ready to get started?Download WordPress

Forums

More Types
Wrong datatype? (20 posts)

  1. dgodfather
    Member
    Posted 3 years ago #

    Warning: in_array() [function.in-array]: Wrong datatype for second argument in .../wp-content/plugins/more-types/more-types-settings.php on line 291

    http://wordpress.org/extend/plugins/more-types/

  2. Sven Peeters
    Member
    Posted 3 years ago #

    I've got the same error

  3. thomasjbradley
    Member
    Posted 3 years ago #

    Yep, same issue.

    Appears on all the settings pages for a specific type.

  4. davidb64il
    Member
    Posted 3 years ago #

    I got it as well.

  5. digitalley
    Member
    Posted 3 years ago #

    Same here>
    Wordpress 3.1 upgrade and Multisite enabled. It happens when I open up the "More types" from settings in sidebar.
    "Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/hs0cgfpq/public_html/wp-content/plugins/more-types/more-types-settings.php on line 291"

    Any Ideas?

  6. admazy
    Member
    Posted 3 years ago #

    any fix?

  7. mediaperfection
    Member
    Posted 3 years ago #

    Try This:
    Paste the following code after line 182 in more-types-object.php:
    $options['show_in_menu'] = true;
    $options['capability_type'] = 'post';

    http://more-plugins.se/forum/topic/more-types-new-post-type-not-appearing-on-left-side-admin-menu

  8. dgodfather
    Member
    Posted 3 years ago #

    So this should be line 183 & 184 respectively?

  9. Jay August
    Member
    Posted 3 years ago #

    Although not a perfect fix, I did manage to get rid of the error by editing more-type-settings.php from line 285 - 296 to this:

    $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(is_array($mytax)) {
                if (in_array($taxonomy->name, $mytax)) $stax[] = $taxonomy;
                } else {
                    $stax[] = NULL;
                }
            }

    This is =not= a perfect fix, but it did got rid of the error. I'm not 100% sure how your custom taxonomies will respond to this!

  10. Jay August
    Member
    Posted 3 years ago #

    Errr... don't do this :) It will wreck your site, sorry.

  11. TrevorNet
    Member
    Posted 3 years ago #

    This worked for me. And by worked, I mean the errors are not showing up and the plug-in continues to work. Right above more-types-settings.php >> 291...

    if(!isset($mytax)) {
       $mytax = array();
    } else if(!is_array($mytax)) {
       settype($mytax, "array");
    }

    This should not interfere with the plug-in (I think) as we are simply forcing $mytax into an array-type. If $mytax already exists as an array, nothing will change. The original in_array() test on 291 will have the proper conditions needed to complete it's task.

  12. dgodfather
    Member
    Posted 3 years ago #

    Thanks TrevorNet, that does get rid of the errors for sure. I'll let you know if I run across other errors.

  13. Tammy Hart
    Member
    Posted 3 years ago #

    Working for me here. Will report errors if encountered.

  14. Volker E.
    Member
    Posted 3 years ago #

    @TrevorNet's fix works for me too (WP 3.1.1/More Types 1.1).

  15. awpile
    Member
    Posted 3 years ago #

    @TrevorNet's fix also worked for me (WP 3.1.1 with two sites networked).

    Just to be clear, lines 285-292 originally look like this:

    $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;
    }

    You add in @TrevorNet's code to line 291, pushing what's on 291 down. So the above block of code now looks like this:

    $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(!isset($mytax)) {
    $mytax = array();
    } else if(!is_array($mytax)) {
    settype($mytax, "array");
    }
    if (in_array($taxonomy->name, $mytax)) $stax[] = $taxonomy;
    }

  16. rajaito
    Member
    Posted 3 years ago #

    @awpile - this worked for me :0)

  17. bixgomez
    Member
    Posted 3 years ago #

    Thank you much, @TrevorNet and @awpile -- this worked for me too! Forgive me, as I am relatively new to the community -- but is there a way to ensure this patch makes it into the next build of this plugin?

  18. owenwalz
    Member
    Posted 2 years ago #

    This happened to me as well. Patch notification?

  19. ramigb
    Member
    Posted 2 years ago #

    The trick that i did was :

    if (is_array($mytax)){
    if (in_array($taxonomy->name, $mytax)) $stax[] = $taxonomy;
    }else{
    $stax[] = '';
    }

    Thank god this is not Java and it's just PHP :P, it works so far i added types no errors what so ever.

    ps: Trevor's Net solution is awesome, and Jay August as well but instead of null just add an empty string.

  20. potel
    Member
    Posted 2 years ago #

    Oh, Thanks for your Help !!! It Works fine for me !! :D

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags