duncanjbrown/plain-route 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

duncanjbrown/plain-route

Composer 安装命令:

composer require duncanjbrown/plain-route

包简介

Define arbitrary endpoints in WordPress

README 文档

README

This library provides a simple interface for WordPress's fiddly rewrite rules API.

It's useful for creating arbitrary endpoints with callbacks. For example, a webhook receiver for a payment gateway.

Usage

Creating an endpoint is accomplished by newing one up. You should do this on init.

add_action( 'init', function() {
  new Plain_Route( 'stripe(/)?', [
    'rewrite' => 'p=123',
    'pre_get_posts' => function( $query ) {
    if( $query->is_main_query() ) {
      $query->set('stripe', true);
    }
  }]);
});

In the above example, pre_get_posts could be replaced with wp_title or wp. Or you could add them alongside.

You can also render any template with the special template callback.

Creating an endpoint that renders a specific template:

add_action( 'init', function() {
 	new Plain_Route( 'my-special-template(/)?', [
 		'template' => 'my-special-template.php'
 	]);
});

Credit

This class is a much-simplified variation of HM_Rewrite by humanmade.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-01-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固