承接 livy/plumbing-templates 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

livy/plumbing-templates

Composer 安装命令:

composer require livy/plumbing-templates

包简介

Put your page (or custom post type) templates in better directories. Works with Sage!

README 文档

README

This tool gives you a way to improve the file organization of your custom page templates. For Wordpress 4.7+ you can also use templates for other post types.

It provides reasonable defaults that should work in most situations, but is also heavily configurable. Ships with built-in support for Sage 10. If you'd like to add built-in support for other frameworks with non-standard template organization, please file a PR or issue.

Usage

First, install the package:

composer require livy/plumbing-templates

Then call the tool like this, somewhere where it'll be run early (i.e. functions.php):

Livy\Plumbing\Templates\register_template_directory('custom-templates');

By default, the package assumes you're changing the template for the page post type, but you can specify any post type by passing a second parameter:

// Define templates for the `event` post type:
Livy\Plumbing\Templates\register_template_directory('event-templates', 'event');

Usually, you'll want to wrap this in an action call to make sure it runs early enough, i.e.:

add_action('init', function () {
    Livy\Plumbing\Templates\register_template_directory('event-templates', 'event');
});

Advanced Usage

This package has a number of other options that allow you to customize its behavior. You can use the project's filters to do this, but it may be easier to pass your arguments all at once. To do this, use setup_template_location() instead of register_template_directory():

Livy\Plumbing\Templates\setup_template_location([
    'paths' => [ 'event-templates' ],
    'post_type' => 'event',
]);

...will have the same effect as the example above.

The keys paths and post_type must be defined, or nothing will happen.

Options

The following is a list of all the options this package understands.

  • paths array - An array of paths (relative to your template root) to search for templates. Default: empty array.
  • post_type string - The post type to use these templates for. Default: page.
  • filename string - Matched against filenames when searching for templates. Can be a string, simple glob (i.e. *.ext) or a regular expression. Default: *.php.
  • template_root string - The template root, which is the directory that all template paths are relative to. It is unlikely you'll need to modify this value. Default: output of get_stylesheet_directory().
  • parent_template_root string - Same as template_root, but for templates in a potential parent theme. Ignored if there is no parent theme. It is unlikely you'll need to modify this value. Default: Output of get_template_directory().
  • contains string - A string templates must contain. Can also be a regular expression. Used to identify what files are templates. Default: Template Name:.
  • name_regex string - A regular expression to get the name of a template from its contents. Default: /Template Name: ?(.+)/.
  • post_type_regex string - A regular expression to determine if a template applies to a particular post type. %post_type% will be replaced with the value of post_type option at runtime. Default: /Template Post Type:.*%post_type%(?=(?:,|$))/m.

Acorn and Sage

If you use the v10+ of the Sage starter theme or are using Acorn in some other capacity, you know that your templates are stored in a slightly non-standard location. Fortunately this package helpfully alters the defaults if it detects that you're using Acorn.

livy/plumbing-templates 适用场景与选型建议

livy/plumbing-templates 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.46k 次下载、GitHub Stars 达 19, 最近一次更新时间为 2018 年 03 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 livy/plumbing-templates 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 livy/plumbing-templates 我们能提供哪些服务?
定制开发 / 二次开发

基于 livy/plumbing-templates 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4.46k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 19
  • 点击次数: 25
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 19
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-03-14