Open widoz opened 5 months ago
I see some tests failing because of the changes, it might make sense to override the BaseProperties::sanitizeBaseName
within the ThemeProperties
instead?
@widoz I think we need to change a bit how it works.
The line substr_count($name, '/') and $name = dirname($name);
in BaseProperties::sanitizeBaseName()
is something that makes sense for plugins. In fact, for plugin we pass the result of plugin_basename()
that with return the-folder/the-file.php
when the plguin is in a folder, but the-file.php
when the plugin is made of a single file.
So I think we should move the entire code of BaseProperties::sanitizeBaseName()
to PluginProperties
.
So, when we have $this->pluginBaseName = plugin_basename($pluginMainFile);
we should do something alomng the lines of:
$basename = plugin_basename($pluginMainFile);
substr_count($basename, '/') and $basename = dirname($name);
$this->pluginBaseName = strtolower(pathinfo($name, PATHINFO_FILENAME));
This way, we should cover all cases for plugin, and it will also be backward compatible for plugins and libraries (which do not use files/directories at all, but Composer name).
At that point, BaseProperties::sanitizeBaseName()
could probably removed at all, or maybe just strtolower($name)
.
PluginProperties
get_stylesheet()
.
The usage of the flag
PATHINFO_FILENAME
might strip part of the name of the project.One case might be a theme having a dot as part of the name, for instance when we want to differentiate the different versions of a theme we have in our installation.
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...) Bug fix
What is the current behavior? (You can also link to an open issue here) The project base name is stripping part of the name when defining the
baseName
propertyWhat is the new behavior (if this is a feature change)? The part after the dot (.) character is no longer stripped off.
Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?) No
Other information: