php - How do I unhook WordPress action hook in plugin file? -


i trying unhook , modify action within child themes functions.php file.

the wordpress plugin sensei, adds action in line 86 of document.

https://github.com/automattic/sensei/blob/master/includes/class-sensei-modules.php#l86

the action references function further down page responsible outputting dynamic header element.

/**  * show title modules on single course template.  *  * function hooked sensei_single_course_modules_before.  *  * @since 1.8.0  * @return void  */  public function course_modules_title( ) {    if( sensei_module_has_lessons() ){         echo '<header><h2>' . __('modules', 'woothemes-sensei') . '</h2></header>';     } } 

my goal here change html output 'modules' else.

i have tried following in child themes functions.php file neither seem working.

remove_action( 'sensei_single_course_modules_before', array( 'sensei_core_modules', 'course_modules_title' ), 20);  remove_action( 'sensei_single_course_modules_before', array( 'sensei()->sensei_core_modules', 'course_modules_title' ), 20); 

the issue is, not know how determine initial parameter, add array call correct class. because accessing externally cannot use $this being used in core file.

in order remove action have find instance of class. assumption since don't have access source code of sensei big chance there 1 since wordpress plug-ins use method.

when find instance name can load using global $senseiinstance - replace actual name of variable.

then can remove action using example code:

remove_action( 'sensei_single_course_modules_before', array( $senseiinstance, 'course_modules_title' ), 20);

more information can found in example article: https://www.sitepoint.com/digging-deeper-wordpress-hooks-filters.

hope helps out!


Comments