Skip to content
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
4 changes: 4 additions & 0 deletions changelog/fix-variable-type-mismatch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Check that author variable is of the expected type
7 changes: 3 additions & 4 deletions includes/class-sensei-modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -2334,8 +2334,8 @@ public static function get_term_authors( $term_name ) {
*
* @since 1.8.0
*
* @param $slug
* @return WP_User $author if no author is found or invalid term is passed the admin user will be returned.
* @param string $slug The term slug to get the author for.
* @return WP_User|false WP_User if found, false if no valid author found.
*/
public static function get_term_author( $slug = '' ) {

Expand Down Expand Up @@ -2721,13 +2721,12 @@ public function append_teacher_name_to_module( $terms, $taxonomies, $args ) {

$author = self::get_term_author( $term->slug );

if ( ! user_can( $author, 'manage_options' ) && isset( $term->name ) ) {
if ( ! user_can( $author, 'manage_options' ) && isset( $term->name ) && $author instanceof WP_User ) {
$term->name = $term->name . ' (' . $author->display_name . ') ';
}

// add the term to the teachers terms
$users_terms[] = $term;

}

return $users_terms;
Expand Down
Loading