calderawp/file-locator
Composer 安装命令:
composer require calderawp/file-locator
包简介
Return a file path or file contents, checking in child theme, then theme, then as an absolute file path.
README 文档
README
Return a file path or file contents, checking in child theme, then theme, then as an absolute file path.
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?
@see https://core.trac.wordpress.org/ticket/13239
License, Copyright etc.
Copyright 2015 CalderaWP LLC & Josh Pollock.
Licensed under the terms of the GNU General Public License version 2 or later. Please share with your neighbor.
The actual file locating code is basically copypasta from https://github.com/pods-framework/pods/blob/master/classes/PodsView (c) Pods Foundation. Much GPL, very thanks.
calderawp/file-locator 适用场景与选型建议
calderawp/file-locator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 70 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「wordpress」 「locate_template」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 calderawp/file-locator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 calderawp/file-locator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 calderawp/file-locator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Must-use plugin integrating WordPress with the Upsun platform: environment awareness, router-cache friendliness, safe preview clones, deploy migrations, Site Health checks, and a wp upsun CLI command.
Inertia.js server-side adapter for PHP. Handles full visits, Inertia XHR visits, asset-version 409 handshakes and partial reloads. Framework-agnostic, with transparent WordPress integration.
Adds Cache-Tag HTTP response headers for singular WordPress content and purges Cloudflare by tag when content changes.
AI Chatbot & Helpdesk Agent for WooCommerce. Connects your store to Egentify for AI-powered chat, order tracking, email, and ticketing.
MIDDAG's reference architecture for a WordPress plugin — composes the OSS framework/wordpress/ui libraries end to end.
Assets helper package for the Hybrid Core framework.
统计信息
- 总下载量: 70
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 20
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2015-02-27