diff --git a/changelog/fix-variable-type-mismatch b/changelog/fix-variable-type-mismatch new file mode 100644 index 0000000000..737138bed0 --- /dev/null +++ b/changelog/fix-variable-type-mismatch @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Check that author variable is of the expected type diff --git a/includes/class-sensei-modules.php b/includes/class-sensei-modules.php index 2af85e74ad..494332e7e0 100644 --- a/includes/class-sensei-modules.php +++ b/includes/class-sensei-modules.php @@ -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 = '' ) { @@ -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 ( $author instanceof WP_User && ! user_can( $author, 'manage_options' ) && isset( $term->name ) ) { $term->name = $term->name . ' (' . $author->display_name . ') '; } // add the term to the teachers terms $users_terms[] = $term; - } return $users_terms;