them-es / starter-bootstrap

Bootstrap 5 WordPress Starter Theme.
https://them.es/starter-bootstrap
GNU General Public License v2.0
146 stars 53 forks source link

Unable to be override files via child themes #32

Open jacktaffa opened 1 month ago

jacktaffa commented 1 month ago

instead of DIR please use get_stylesheet_directory() so it will possible to override files via child theme

them-es commented 1 month ago

Hi @jacktaffa,

thanks for your suggestion. The downside of including get_stylesheet_directory() functions is performance as it uses function calls and filters to retrieve the directory of the active theme:

/**
 * Retrieves stylesheet directory path for the active theme.
 *
 * @since 1.5.0
 * @since 6.4.0 Memoizes filter execution so that it only runs once for the current theme.
 * @since 6.4.2 Memoization removed.
 *
 * @return string Path to active theme's stylesheet directory.
 */
function get_stylesheet_directory() {
    $stylesheet     = get_stylesheet();
    $theme_root     = get_theme_root( $stylesheet );
    $stylesheet_dir = "$theme_root/$stylesheet";

    /**
     * Filters the stylesheet directory path for the active theme.
     *
     * @since 1.5.0
     *
     * @param string $stylesheet_dir Absolute path to the active theme.
     * @param string $stylesheet     Directory name of the active theme.
     * @param string $theme_root     Absolute path to themes directory.
     */
    return apply_filters( 'stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root );
}

__DIR__ is a plain PHP constant.

In the end you'd have to search/replace this value only four times in your functions.php to achieve what you want. And frankly, this is an edge case, as the majority of users don't combine this Starter Theme with a Child Theme. So there is a slight preference to keep it the way it is.

Is this ok for you?

jacktaffa commented 1 month ago

ok , Idk about how many milliseconds we are talking about, but if this theme it will have no updates I think it's okay replacing when there's the necessity of child theme