Join GitHub today
Hide comments when lesson has not dripped #173
This change fixes the issue that lesson comments where visible although the lesson was not accessible due to content drip. It relies on the filter that was added with this PR.
This change has a dependency on this change in Sensei core. Although there will be no errors if one of the two is merged without the other, we need both for the functionality to work.
alexsanford left a comment
Instead of adding a filter to Sensei, what do you think of just removing the action that outputs the comments? I.e.
remove_action( 'sensei_pagination', [ 'Sensei_Lesson', 'output_comments' ], 90 );
Of course we would need to wrap it in the logic for whether the comments should be displayed.
The benefit of doing this is that we wouldn't have to add another filter, and we wouldn't be dependent on the Sensei release (with the new filter) in order for this to work.
I think that in general the solution with the new hook is a bit cleaner since with the new hook all the functionality is going to be in a single place, in output_comments method.
However adding a hook increases complexity and introduces this dependency so I think that it's worth to remove the existing action instead.
I agree, and it also means that there are two ways to do the same thing (i.e. use the filter or remove the action). Either one is a common practice in WordPress-land, so having the two different ways could cause confusion.