How to remove a class function from a plugin by using remove_action()?

[ Nova_Restaurant::init(), 'sort_menu_item_queries_by_menu_order' ]

You want something of type callable, that matches what was given when add_action.

There are only a handful of valid callables:

  • [ 'my_function_name' ] aka my_function_name();
  • [ 'my_class_name', 'my_static_function' ] aka my_class_name::my_stati_function()
  • [ $object, 'the_objects_function' ] aka $object->the_objects_function
  • [ function() {} ] an anonymous function or closure

So some translation:

  • remove_action('parse_query','WM_Nova_Restaurant', 10);
    • Remove the function named WM_Nova_Restaurant from the parse_query hook
  • remove_action('parse_query', 'WM_Nova_Restaurant>sort_menu_item_queries_by_menu_order', 10);
    • Remove the function named WM_Nova_Restaurant>sort_menu_item_queries_by_menu_order from the parse_query hook. Note such a function name is not possible.
  • remove_action('parse_query',array("WM_Nova_Restaurant", "sort_menu_item_queries_by_menu_order"), 10);
    • Remove the static method sort_menu_item_queries_by_menu_order in the WM_Nova_Restaurant class from the hook
  • remove_action('parse_query', array("WM_Nova_Restaurant", "sort_menu_item_queries_by_menu_order"), 1);
    • Remove the static method sort_menu_item_queries_by_menu_order in the WM_Nova_Restaurant class from the hook, that has priority 1
  • remove_action('parse_query',array($WM_Nova_Restaurant, "sort_menu_item_queries_by_menu_order"), 10);
    • Remove the method sort_menu_item_queries_by_menu_order in the object $WM_Nova_Restaurant from the hook. Note that this object is empty so it is also invalid.

In future:

  • Search for the place it was added
  • Read the WP and PHP docs instead of guessing and flailing around
  • See that it’s added inside an object and try to figure out how to get a hold of that object by looking at how it’s created
  • See that the object is created by calling Nova_Restaurant::init()

error code: 523