2016-08-01 14:46
浏览 55


I am trying to unhook and modify an action from within my child themes functions.php file.

The WordPress plugin Sensei, adds this action in line 86 of this document.


The action references a function further down the page that is responsible for outputting a dynamic header element.

 * Show the title modules on the single course template.
 * Function is hooked into 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 is to change the html currently output as 'Modules' to something else.

I have tried to the following in my child themes functions.php file but neither seem to be 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, I do not know how to determine which initial parameter, to add to the array to call the correct class. Because I am accessing it externally I cannot use $this like it is being used in the core file.

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dsbpaqt61965 2016-08-01 18:54

    In order to remove the action you have to find the instance of the class. This is an assumption since I don't have access to the source code of Sensei but big chance there is one since most WordPress plug-ins use this method.

    When you find the instance name you can load it using global $senseiInstance - replace this with the actual name of the variable.

    Then you can remove the action using for example this code:

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

    More information can be found in for example this article: https://www.sitepoint.com/digging-deeper-wordpress-hooks-filters.

    Hope this helps you out!

    打赏 评论

相关推荐 更多相似问题