PHPackages                             markzero/wp-on-routes - 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. [API Development](/categories/api)
4. /
5. markzero/wp-on-routes

ActiveWordpress-plugin[API Development](/categories/api)

markzero/wp-on-routes
=====================

WordPress plugin that adds API-like functionality by allowing you to add custom routes

1462[3 issues](https://github.com/markzero/wp-on-routes/issues)PHP

Since Oct 13Pushed 10y ago3 watchersCompare

[ Source](https://github.com/markzero/wp-on-routes)[ Packagist](https://packagist.org/packages/markzero/wp-on-routes)[ RSS](/packages/markzero-wp-on-routes/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

WordPress on Routes
===================

[](#wordpress-on-routes)

WordPress on Routes is a plugin for WordPress, inspired mainly by Ruby micro-frameworks. It adds ability to add custom routes to your WordPress instance. Useful for form submissions, API-like features, etc.

It's also hosted under Plugins repo: .

Installation
============

[](#installation)

Good old plugin installation applies here too - download it / clone it to `plugins/` dir, activate.

No UI involved.

Basic Usage
===========

[](#basic-usage)

In your functions.php:

```
$routing = \WoR\Main::get_instance();

$routing->add_routes(
  array(
    'get' => array(
      'path' => '/foo/bar',
      'body' => 'Hello Buz!',
      'headers' => array(
        'Content-Type' => 'text/html; charset=UTF-8',
        'exclude' => array(
          'x-powered-by', 'x-pingback'
        )
      )
    )
  )
);
```

Naturally, you have to check for class existence (e.g. in `lib/routes.php` file):

```
if (!class_exists('\WoR\Main')) {
  return;
}
```

And use it in `functions.php`:

```
require_once('lib/routes.php');
```

Remember, because of using namespaces your PHP installation version must be [&gt;= 5.3.0](http://www.php.net/manual/en/language.namespaces.rationale.php).

Extended Usage
==============

[](#extended-usage)

```
function wor_dump() {
  var_dump($_GET);
}

add_action('wor_action', 'wor_dump');

$routing = \WoR\Main::get_instance();

$routing->add_routes(
  array(
    'get' => array(
      'path' => '/foo/*/bar/:p1?',
      'action' => 'wor_action',
      'agent' => '/Firefox/',
      'include_template' => true
    )
  )
);
```

In example above, if you target `/foo/a/b/c/bar/test`, browser will answer with HTTP status 200, with following code, with header and footer included, only in Firefox browser:

```
array (size=2)
  'p1' => string 'test' (length=4)
  'splats' =>
    array (size=1)
      0 => string 'a/b/c' (length=5)

```

Details
=======

[](#details)

At this point there are several capabilities:

1. Add custom routes to your WordPress installation
2. Set method GET/POST/DELETE etc.
3. Set body (as text, or template) or action (using add/do\_action). If both are defined, `action` takes precedence over `body`.
4. Set header (e.g. 'Content-Type' =&gt; 'text/html; charset=UTF-8')
5. Exclude header (e.g. 'Set-Cookie')
6. Set parameters like `/my/route/:param1/:param2` or as splats `/foo/*/bar`
7. Add agents or filter by agents, using regular expressions
8. Agent filter for negative logic (e.g. `/^((?!Firefox).)*$/`, which tells "every browser except Firefox")
9. Include header and footer

Options you can set:

1. `path` (string)
2. `body` OR `action` (string)
3. `agent` (string/regex)
4. `include_template` (boolean; default: false)
5. `headers` (array)

- `exclude` (array)

Tests
=====

[](#tests)

Reference to tests/instructions.txt to read how to test output of your WordPress website.

I am using wp-cli to generate testing environment: .

So, before any testing run similar command: `bash bin/install-wp-tests.sh wor_test_db root root localhost latest`.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.4% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ff0262ffc3907057de3879ec8e1afd2860b99c410feeb014b0a415a3fc06708?d=identicon)[markzero](/maintainers/markzero)

---

Top Contributors

[![mk0y](https://avatars.githubusercontent.com/u/170480?v=4)](https://github.com/mk0y "mk0y (61 commits)")[![danielbachhuber](https://avatars.githubusercontent.com/u/36432?v=4)](https://github.com/danielbachhuber "danielbachhuber (1 commits)")

### Embed Badge

![Health badge](/badges/markzero-wp-on-routes/health.svg)

```
[![Health](https://phpackages.com/badges/markzero-wp-on-routes/health.svg)](https://phpackages.com/packages/markzero-wp-on-routes)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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