GaryJones / Gamajo-Template-Loader

A class to copy into your WordPress plugin, to allow loading template parts with fallback through the child theme > parent theme > plugin.
GNU General Public License v2.0
292 stars 61 forks source link

Inherited static properties breaks template_paths() #45

Closed zackkatz closed 2 years ago

zackkatz commented 2 years ago

In PHP 8.1, If a class is extended, static methods aren't inherited. In this case, the static $file_paths; definition isn't inherited.

class Example_Template extends Gamajo_Template_Loader {}
class Example_Template_Two extends Example_Template {}

$one = new Example_Template();

$two = new Example_Template_Two();
$two->plugin_template_directory = 'path-override'

$one->locate_template(); // Paths are added, returns true
$two->locate_template(); // New paths aren't added, returns false

I propose switching to a private property instead. PR incoming.

zackkatz commented 2 years ago

I'm sorry, this is not an issue with the current version. We're using 1.3.1 in our plugin but it doesn't match up with 1.3.1 here! Not sure exactly how that happened…

Anyway, thanks for this class!