WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
[resolved] Infinite search wheel (7 posts)

  1. Jared Atchison
    Member
    Posted 3 years ago #

    I have Clients and Projects CTPs which I registered with CPT UI.

    In my functions...

    function my_connection_types() {
        if ( !function_exists('p2p_register_connection_type') )
            return;
    
        p2p_register_connection_type( 'projects', 'clients', true );
    }
    add_action('init', 'my_connection_types', 100);

    Metabox shows up fine.

    I have added a client called Eric Brown. When type in 'Eric' into the metabox, it begins searching then gives me this response (from firebug)

    <br />
    <b>Warning</b>:  Invalid argument supplied for foreach() in <b>/Users/Jared/Sites/htdocs/projects/wp-admin/includes/plugin.php</b> on line <b>1264</b><br />
    <br />
    <b>Warning</b>:  Invalid argument supplied for foreach() in <b>/Users/Jared/Sites/htdocs/projects/wp-admin/includes/plugin.php</b> on line <b>1264</b><br />
    <br />
    <b>Warning</b>:  Invalid argument supplied for foreach() in <b>/Users/Jared/Sites/htdocs/projects/wp-admin/includes/plugin.php</b> on line <b>1264</b><br />
    <br />
    <b>Warning</b>:  Invalid argument supplied for foreach() in <b>/Users/Jared/Sites/htdocs/projects/wp-admin/includes/plugin.php</b> on line <b>1264</b><br />
    <br />
    <b>Warning</b>:  Invalid argument supplied for foreach() in <b>/Users/Jared/Sites/htdocs/projects/wp-admin/includes/plugin.php</b> on line <b>1264</b><br />
    {"27":"Eric Brown"}

    This is on a fresh 3.1 RC3 install.

    Any ideas where to look?

  2. Jared Atchison
    Member
    Posted 3 years ago #

    Very strange. So I tracked down line 1264 and it had to do with remove_menu_page which I was indeed using.

    Once I commented out this

    //add_action('admin_init', 'remove_admin_menus');
    function remove_admin_menus(){
    	remove_menu_page('edit.php'); // Posts
    	remove_menu_page('upload.php'); // Media
    	remove_menu_page('link-manager.php'); // Links
    	remove_menu_page('edit-comments.php'); // Comments
    	remove_menu_page('tools.php'); // Tools
    }

    and tried it again the searched worked without any issues.

  3. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    'admin_init' will fire for ajax requests too. You should be using 'admin_menu' instead.

  4. Jared Atchison
    Member
    Posted 3 years ago #

    Thanks scribu!

    Originally I was actually looking at your usage example on trac :P

    http://core.trac.wordpress.org/ticket/14666#comment:6

    Much appreciated!

  5. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    Corrected. ;)

  6. jay.weeks
    Member
    Posted 3 years ago #

    I made this same mistake, using the correct admin_menu will also fix some style issues that result from using admin_init to remove menus (when removing comments menu the pages menu is left at the bottom of a menu group without the proper classes)

  7. liperuf
    Member
    Posted 3 years ago #

    Thanks @scribu!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic