定制 victorhugobatista/wp-eruptor 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

victorhugobatista/wp-eruptor

Composer 安装命令:

composer require victorhugobatista/wp-eruptor

包简介

Extend your single pages like lava in the water with less setup

README 文档

README

Extend your single pages like lava in the water with less setup

screenshot

Simple usage

Add the lib by composer with the command below:

composer require victorhugobatista/wp-eruptor

Add the code below to your functions. Where the template files will be loaded by default at active-theme-dir/single-page-children.

use victorhugobatista\WpEruptor\Eruptor;
Eruptor::initialize();

You can pass the root directory where the templates will be loaded as the example below:

use victorhugobatista\WpEruptor\Eruptor;

$themePath = get_template_directory();
$templateToInclude = "{$themePath}/my-custom-template-dir";

Eruptor::initialize($templateToInclude);

Template files

The file structure to place the templates must be like below:

  • Template root directory (by now, the template folder must be placed here)
    • single-page-children (by now, this name can't be changed)
      • single-book (this represents the name of template file of single pages, in case single-book.php)
        • child-a.php (/book/existing-post-name/child-a)
        • child-b.php (/book/existing-post-name/child-b)
        • child-c.php (/book/existing-post-name/child-c)
      • single-movie
        • child-d.php (/movie/existing-post-name/child-d)
        • child-e.php (/movie/existing-post-name/child-e)
        • child-f.php (/movie/existing-post-name/child-f)

The post id of parent single page will be available in the templates as:

<?php echo $pageData['post-id'] ?>

Hooks reference

Hook Description
eruptor/data Inject data to all templates
eruptor/data/type/{post-type-slug} Inject data to templates children of posts of an post type by slug
eruptor/data/post/{parent-single-post-id} Inject data to templates children of an specific post by id
eruptor/data/template/{template-slug} Inject data to one template by name

Example for eruptor/data* hook:

/!\ The wildcard * can be replace with any eruptor/data filters above /!\

add_filter('eruptor/data*', function($data) {
  return array_merge($data, [
    'new-data' => 'new data added to template',
  ]);
});

The new data will be available on template on $pageData array:

<?php echo $pageData['new-data'] ?>

Next steps (from @todo comments added to the code)

  • To receive what post types have to be added to routes on main class.
  • Add filters to allow the modification of header, content and footer by post type, post name and template name.

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-11-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固