WordPress.org

Ready to get started?Download WordPress

Forums

Jetpack Only for Admins
conflict with AJAX due to PHP warning (5 posts)

  1. kitchin
    Member
    Posted 7 months ago #

    This could be the source of other bugs reported here.

    We are getting a debug warning that breaks AJAX responses, even though WP_DEBUG is off. Here is a fix:

    * Updated to use the fix suggested here: http://wordpress.org/support/topic/warning-while-using-wp-cli *

    Version: 1.1, file jp-rm-jpmenu.php, line 36:

    add_action( 'admin_init', 'jp_rm_menu' );

    Change to:

    add_action( 'admin_menu', 'jp_rm_menu' );

    The error we are seeing is in remove_menu_page():

    <b>Warning</b>:  Invalid argument supplied for foreach() in <b>.../wp-admin/includes/plugin.php</b> on line <b>1375</b><br />

    http://wordpress.org/plugins/jetpack-only-for-admins/

  2. The Merovingian
    Member
    Posted 7 months ago #

    I have not encountered this bug on my WP site. However using 'admin_init' correctly hides the Jetpack menu items, but 'admin_menu' does NOT.

  3. kitchin
    Member
    Posted 6 months ago #

    Well, I believe my other fix was something like if (defined('DOING_AJAX') && DOING_AJAX) return;. You don't need to add menus in admin_init when doing AJAX.

    But the correct way is probably 'admin_menu'. Maybe change the priority so it works with JetPack?

  4. mhixon
    Member
    Posted 4 months ago #

    I am experiencing the same issue where if I change 'admin_init' to 'admin_menu' then it resolves the errors, but no longer hides the Jetpack menu item.

    Could you elaborate on how exactly to implement one of your other fixes?

  5. kitchin
    Member
    Posted 1 month ago #

    Try this:

    Version: 1.1, file jp-rm-jpmenu.php, line 36:

    add_action( 'admin_init', 'jp_rm_menu' );

    Change to:

    add_action( 'admin_menu', 'jp_rm_menu', 2000 );
    // Note Jetpack 3.0.2 uses 'admin_menu' priority 998 and 999

Reply

You must log in to post.

About this Plugin

About this Topic