Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3307: Removes empty lessons section & title from single course page. #3308

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions includes/class-sensei-course.php
Original file line number Diff line number Diff line change
Expand Up @@ -2810,7 +2810,7 @@ public static function the_course_lessons_title() {

} elseif ( empty( $none_module_lessons ) ) { // if the none module lessons are simply empty the title should not be shown

$title = '';
return;
}

/**
Expand Down Expand Up @@ -3161,7 +3161,7 @@ public static function the_course_video() {
}

/**
* Output the title for the single lesson page
* Output the title for the single course page
*
* @global $post
* @since 1.9.0
Expand All @@ -3173,23 +3173,21 @@ public static function the_title() {
}
global $post;

?>
<header>

<h1>

<?php
/**
* Filter documented in class-sensei-messages.php the_title
*/
echo wp_kses_post( apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type ) );
?>

</h1>

</header>

<?php
/**
* Filter documented in class-sensei-messages.php the_title
*/
$title = wp_kses_post( apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type ) );
if ( $title ) :
?>
<header>
<h1>
<?php
echo wp_kses_post( $title );
?>
</h1>
</header>
<?php
endif;

}//end the_title()

Expand Down
40 changes: 20 additions & 20 deletions includes/class-sensei-lesson.php
Original file line number Diff line number Diff line change
Expand Up @@ -4184,30 +4184,30 @@ public static function the_title() {
$is_preview = isset( $post->ID )
&& Sensei_Utils::is_preview_lesson( $post->ID )
&& ! Sensei_Course::is_user_enrolled( $course_id, $current_user->ID );

?>
<header class="lesson-title">

<h1>

<?php
/**
* Filter documented in class-sensei-messages.php the_title
*/
echo wp_kses_post( apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type ) );
/**
* Filter documented in class-sensei-messages.php the_title
*/
$title = wp_kses_post( apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type ) );
if ( $title || $is_preview ) :
?>
<header class="lesson-title">
<?php if ( $title ) : ?>
<h1>
<?php
echo wp_kses_post( $title );
?>
</h1>
<?php
endif;
if ( $is_preview ) {
echo wp_kses_post( Sensei()->frontend->sensei_lesson_preview_title_tag( $course_id ) );
}
?>

</h1>
</header>

<?php
if ( $is_preview ) {
echo wp_kses_post( Sensei()->frontend->sensei_lesson_preview_title_tag( $course_id ) );
}
?>

</header>

<?php
endif;

}//end the_title()

Expand Down
46 changes: 21 additions & 25 deletions includes/class-sensei-messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -745,31 +745,27 @@ public static function the_title() {
} else {
$title = esc_html( get_the_title( $post->ID ) );
}

?>
<header>

<h1>

<?php
/**
* Filter Sensei single title
*
* @since 1.8.0
* @param string $title
* @param string $template
* @param string $post_type
*/
echo wp_kses_post( apply_filters( 'sensei_single_title', $title, $post->post_type ) );
?>

</h1>

</header>

<?php

} // End sensei_single_title()
/**
* Filter Sensei single title
*
* @since 1.8.0
* @param string $title
* @param string $template
* @param string $post_type
*/
$title = wp_kses_post( apply_filters( 'sensei_single_title', $title, $post->post_type ) );
if ( $title ) :
?>
<header>
<h1>
<?php
echo wp_kses_post( $title );
?>
</h1>
</header>
<?php
endif;
}//end the_title()

/**
* Generates the my messages
Expand Down
32 changes: 15 additions & 17 deletions includes/class-sensei-quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -1184,23 +1184,21 @@ public static function stop_quiz_questions_loop() {
* @since 1.9.0
*/
public static function the_title() {
?>
<header>

<h1>

<?php
/**
* Filter documented in class-sensei-messages.php the_title
*/
echo wp_kses_post( apply_filters( 'sensei_single_title', get_the_title( get_post() ), get_post_type( get_the_ID() ) ) );
?>

</h1>

</header>

<?php
/**
* Filter documented in class-sensei-messages.php the_title
*/
$title = wp_kses_post( apply_filters( 'sensei_single_title', get_the_title( get_post() ), get_post_type( get_the_ID() ) ) );
if ( $title ) :
?>
<header>
<h1>
<?php
echo wp_kses_post( $title );
?>
</h1>
</header>
<?php
endif;
}//end the_title()

/**
Expand Down
129 changes: 61 additions & 68 deletions templates/single-course/lessons.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,97 +7,90 @@
* @author Automattic
* @package Sensei
* @category Templates
* @version 1.9.0
* @version 3.2.0
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>

<section class="course-lessons">

<?php

/**
* Actions just before the sensei single course lessons loop begins
*
* @hooked Sensei_Course::load_single_course_lessons_query
* @since 1.9.0
*/
do_action( 'sensei_single_course_lessons_before' );
/**
* Actions just before the sensei single course lessons loop begins
*
* @hooked Sensei_Course::load_single_course_lessons_query
* @since 1.9.0
*/
do_action( 'sensei_single_course_lessons_before' );

// lessons loaded into loop in the sensei_single_course_lessons_before hook
if ( have_posts() ) :
?>

<?php
<section class="course-lessons">

// lessons loaded into loop in the sensei_single_course_lessons_before hook
if ( have_posts() ) :
<?php
// start course lessons loop
while ( have_posts() ) :
the_post();
?>

<article <?php post_class(); ?> >

<?php

/**
* The hook is inside the course lesson on the single course. It fires
* for each lesson. It is just before the lesson excerpt.
*
* @since 1.9.0
*
* @param $lessons_id
*
* @hooked Sensei_Lesson::the_lesson_meta - 5
* @hooked Sensei_Lesson::the_lesson_thumbnail - 8
*/
do_action( 'sensei_single_course_inside_before_lesson', get_the_ID() );

// start course lessons loop
while ( have_posts() ) :
the_post();
?>

<article <?php post_class(); ?> >
<section class="entry">

<?php

/**
* The hook is inside the course lesson on the single course. It fires
* for each lesson. It is just before the lesson excerpt.
*
* @since 1.9.0
*
* @param $lessons_id
*
* @hooked Sensei_Lesson::the_lesson_meta - 5
* @hooked Sensei_Lesson::the_lesson_thumbnail - 8
*/
do_action( 'sensei_single_course_inside_before_lesson', get_the_ID() );

/**
* Display the lesson excerpt
*/
the_excerpt();
?>

<section class="entry">

<?php
/**
* Display the lesson excerpt
*/
the_excerpt();
?>
</section>

</section>
<?php

<?php

/**
* The hook is inside the course lesson on the single course. It is just before the lesson closing markup.
* It fires for each lesson.
*
* @since 1.9.0
*/
do_action( 'sensei_single_course_inside_after_lesson', get_the_ID() );

?>
/**
* The hook is inside the course lesson on the single course. It is just before the lesson closing markup.
* It fires for each lesson.
*
* @since 1.9.0
*/
do_action( 'sensei_single_course_inside_after_lesson', get_the_ID() );

</article>
?>

<?php endwhile; // end course lessons loop ?>
</article>

<?php endif; ?>
<?php endwhile; // end course lessons loop ?>

<?php
</section>

/**
* Actions just before the sensei single course lessons loop begins
*
* @hooked Sensei_Course::reset_single_course_query
*
* @since 1.9.0
*/
do_action( 'sensei_single_course_lessons_after' );
<?php endif;

?>
/**
* Actions just before the sensei single course lessons loop begins
*
* @hooked Sensei_Course::reset_single_course_query
*
* @since 1.9.0
*/
do_action( 'sensei_single_course_lessons_after' );

</section>
?>