Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Fix template loading in template_files method to account for child themes  #23

@actual-saurabh

Description

@actual-saurabh

In lines https://github.com/yapapaya/live-comment-preview/blob/master/classes/class-live-comment-preview.php#L190-L193
$files = array( 'user' => get_stylesheet_directory() . '/comment-preview.php', 'theme' => get_stylesheet_directory() . '/comments.php', );
only looks for the files in the current theme.

This does not account for a child theme/parent theme relationship. See how WordPress's locate_template function works in https://github.com/WordPress/WordPress/blob/master/wp-includes/template.php#L605-L639

I used it on a child theme and it ended up returning an empty array.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions