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. [File &amp; Storage](/categories/file-storage)
4. /
5. calderawp/file-locator

ActiveLibrary[File &amp; Storage](/categories/file-storage)

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 today

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 47% 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

4146d 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

[humanmade/network-media-library

Network Media Library provides a central media library that's shared across all sites on the Multisite network.

29745.6k](/packages/humanmade-network-media-library)[ilab/ilab-media-tools

Tools for cropping, uploading to S3, serving through Imgix

120104.0k1](/packages/ilab-ilab-media-tools)[wptt/webfont-loader

Locally host webfonts.

12658.6k2](/packages/wptt-webfont-loader)[dre1080/wp-graphql-upload

Adds file upload support to the WP GraphQL Plugin.

3865.0k](/packages/dre1080-wp-graphql-upload)[mcguffin/acf-dropzone

Drag and drop file upload for ACF-Fields.

339.2k](/packages/mcguffin-acf-dropzone)

PHPackages © 2026

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