PHPackages                             calderawp/file-locator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. calderawp/file-locator

ActiveLibrary

calderawp/file-locator
======================

Return a file path or file contents, checking in child theme, then theme, then as an absolute file path.

1.0.0(11y ago)2701GPL-2.0+PHPPHP &gt;=5.3.0

Since Feb 27Pushed 11y ago2 watchersCompare

[ Source](https://github.com/CalderaWP/file-locator)[ Packagist](https://packagist.org/packages/calderawp/file-locator)[ RSS](/packages/calderawp-file-locator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (1)

CalderaWP File Loader
=====================

[](#calderawp-file-loader)

Return a file path or file contents, checking in child theme, then theme, then as an absolute file path.

### Usage

[](#usage)

```
    //Load a file called "food.html" from current themes "templates" folder
    $file = calderawp_file_locator( 'templates/food.html' );
    if ( is_string( $file ) ) {
        echo $file;
    }

    //load a php file from your plugin, if a file "noms.php" of same name is not in template
    $file = calderawp_file_locator( 'noms.php' );

    //By default only file extensions php|html|htm are allowed.
    //TO override this use the "calderawp_file_locator_allow_extensions" filter before calling it, like this:
    add_filter( 'calderawp_file_locator_allow_extensions', function( $allowed, $context ) {
    	if ( 'slug_json_loader' === $context ) {
    		$allowed = array( 'json' );
    	}

    	return $allowed;

    }, 10, 2 );

    return calderawp_file_locator( 'hats.json', 'slug_json_loader' );

    //Use a special single-{$post-type}.php, in this case single-hat.php from plugin if theme/child theme doesn't have that file.
add_filter( 'template_includes', function( $template ) {
	if ( 'single-hat.php' == $template && ! is_file( calderawp_file_locator( $template ) ) ) {
		$template = calderawp_file_locator( trailingslashit( plugin_dir_path( __FILE__ ) ) . $template );
	}

	return $template;

}, 10 );

```

### Can't you do this in WordPress Already?

[](#cant-you-do-this-in-wordpress-already)

@see

### License, Copyright etc.

[](#license-copyright-etc)

Copyright 2015 [CalderaWP LLC](https://CalderaWP.com) &amp; [Josh Pollock](http://JoshPress.net).

Licensed under the terms of the [GNU General Public License version 2](http://www.gnu.org/licenses/gpl-2.0.html) or later. Please share with your neighbor.

The actual file locating code is basically copypasta from  (c) Pods Foundation. Much GPL, very thanks.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4090d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ca938daf3f2a666cd32c7bdb6e30714da6fe0e6cd5012fe4864b18afae43fbcd?d=identicon)[Shelob9](/maintainers/Shelob9)

---

Top Contributors

[![Shelob9](https://avatars.githubusercontent.com/u/1994311?v=4)](https://github.com/Shelob9 "Shelob9 (2 commits)")

---

Tags

wordpresslocate\_template

### Embed Badge

![Health badge](/badges/calderawp-file-locator/health.svg)

```
[![Health](https://phpackages.com/badges/calderawp-file-locator/health.svg)](https://phpackages.com/packages/calderawp-file-locator)
```

###  Alternatives

[roots/wordpress

WordPress is open source software you can use to create a beautiful website, blog, or app.

19116.9M257](/packages/roots-wordpress)[aristath/kirki

Extending the WordPress customizer

1.3k73.0k4](/packages/aristath-kirki)[wpreadme2markdown/wpreadme2markdown

Convert WordPress Plugin readme.txt to Markdown

9564.6k4](/packages/wpreadme2markdown-wpreadme2markdown)[wpstarter/framework

The WpStarter Framework - Laravel Framework for WordPress

1810.1k4](/packages/wpstarter-framework)[tacowordpress/tacowordpress

WordPress custom post types that feel like CRUD models

232.2k](/packages/tacowordpress-tacowordpress)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
