0

Result of the var_dump('parse_query'):

 WP_Hook::__set_state(array(
    'callbacks' => 
    array (
    10 => 
      array (
       '0000000003c8dc5e000000004a442b5dsort_menu_item_queries_by_menu_order' => 
      array (
         'function' => 
       array (
      0 => 
      WM_Nova_Restaurant::__set_state(array(
         'version' => '0.1',
         'default_menu_item_loop_markup' => 
        array (
          'menu_tag' => 'section',
          'menu_class' => 'menu-items',
          'menu_header_tag' => 'header',
          'menu_header_class' => 'menu-group-header',
          'menu_title_tag' => 'h1',
          'menu_title_class' => 'menu-group-title',
          'menu_description_tag' => 'div',
          'menu_description_class' => 'menu-group-description',
        ),
         'menu_item_loop_markup' => 
        array (
          'menu_tag' => 'section',
          'menu_class' => 'menu-items',
          'menu_header_tag' => 'header',
          'menu_header_class' => 'menu-group-header',
          'menu_title_tag' => 'h2',
          'menu_title_class' => 'menu-group-title',
          'menu_description_tag' => 'div',
          'menu_description_class' => 'menu-group-description',
        ),
         'menu_item_loop_last_term_id' => false,
         'menu_item_loop_current_term' => false,
      )),
      1 => 'sort_menu_item_queries_by_menu_order',
    ),
    'accepted_args' => 1,
  ),
),
),
 'iterations' => 
  array (
   ),
  'current_priority' => 
 array (
  ),
   'nesting_level' => 0,
   'doing_action' => false,
  ))

I have tried these, but none of it worked:

 function RBTM_my_func(){
  global $WM_Nova_Restaurant;
  remove_action('parse_query','WM_Nova_Restaurant', 10); 
  remove_action('parse_query', 'WM_Nova_Restaurant>sort_menu_item_queries_by_menu_order', 10); 
  remove_action('parse_query',array("WM_Nova_Restaurant", "sort_menu_item_queries_by_menu_order"), 10); 
  remove_action('parse_query', array("WM_Nova_Restaurant", "sort_menu_item_queries_by_menu_order"), 1);
  remove_action('parse_query',array($WM_Nova_Restaurant, "sort_menu_item_queries_by_menu_order"), 10);
  do_hard_unregister_object_callback( 'parse_query', 10, 'RBTM_my_func');
 }
  add_action('parse_tax_query', 'RBTM_my_func', 10);

So how do I remove this particular class function? WM_Nova_Restaurant->sort_menu_item_queries_by_menu_order link

I tried seeking for answers but couldn't find anything. Any help would be much appreciated, thanks!!!

8
  • It depends how they were originally hooked. Is sort_menu_item_queries_by_menu_order hooked as a static method? Is there a global variable for an instance of WM_Nova_Restaurant? Is WM_Nova_Restaurant a singleton? It's not possible to answer this question without knowing answers to those questions. If you don't know how to find out you need to contact the plugin author. – Jacob Peattie Jun 25 '18 at 15:16
  • screencast.com/t/PxF3iOcUk - isn't this enough? or are there any plugins to know the info of that function inside the hook & how to possibly remove it? or just var_dump() like what i did with the hook parse_query – Ray Macz Jun 25 '18 at 15:25
  • @RayMacz can you find the code that does the add_action call? It's incredibly difficult if not near impossible to tell just from that Query Monitor output. Looking for that class in the source code is an unavoidable step – Tom J Nowell Jun 25 '18 at 15:52
  • @TomJNowell Thanks, I tried searching the whole theme directory files, but couldn't find the function or method sort_menu_item_queries_by_menu_order so I searched for the class WM_Nova_Restaurant instead, & these are all the add_action() I got (using netbeans): screencast.com/t/e4d3rmtX4Ki I guess this is hopeless, & I need to ask the plugin developer. Many thanks guys... – Ray Macz Jun 25 '18 at 16:33
  • Did you search the Plugins directory too? What's the context of that line that was found? It looks like you need to acquire the instance of that object in order to remove it, but there's not enough information, it isn't clear where that line is, or which plugin or theme is responsible? – Tom J Nowell Jun 25 '18 at 16:49
1
[ 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()
1
  • Thank you so much for your time, effort & esp. your patience. A hero to the WP Community. Cheers! – Ray Macz Jun 25 '18 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.