PHPackages                             arraypress/wp-register-pages - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. arraypress/wp-register-pages

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

arraypress/wp-register-pages
============================

Dead simple page detection and registration for WordPress plugins

212PHP

Since Nov 23Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/arraypress/wp-register-pages)[ Packagist](https://packagist.org/packages/arraypress/wp-register-pages)[ RSS](/packages/arraypress-wp-register-pages/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

WordPress Page Registration
===========================

[](#wordpress-page-registration)

Dead simple page registration for WordPress plugins. Creates pages on activation, stores their IDs in a format compatible with settings managers, and shows post states in the admin.

Install
-------

[](#install)

```
composer require arraypress/wp-page-utils
```

Basic Usage
-----------

[](#basic-usage)

```
use ArrayPress\PageUtils\Register;

// Create registrar
$register = new Register('myplugin');

// Add pages
$register->add('checkout', 'Checkout', '[myplugin_checkout]');
$register->add('account', 'My Account', '[myplugin_account]');
$register->add('success', 'Order Complete', 'Thank you for your order!');

// Create the pages (post states are enabled by default)
$page_ids = $register->install();

// Now in WordPress admin, you'll see:
// Pages list: "Checkout — Myplugin Checkout"
// Pages list: "My Account — Myplugin Account"
```

Post States Feature
-------------------

[](#post-states-feature)

When you register pages, they automatically show up with labels in the WordPress admin pages list:

```
// Your pages will show in admin like:
// ✓ Checkout     — MyPlugin Checkout
// ✓ My Account   — MyPlugin Account
// ✓ Thank You    — MyPlugin Success

// Disable post states if you don't want them
$register->install(false); // Pass false to disable

// Or with quick install
Register::quick_install($pages, 'myplugin', null, null, false);
```

With Settings Manager
---------------------

[](#with-settings-manager)

The library stores page IDs in a format compatible with your settings manager:

```
use ArrayPress\PageUtils\Register;
use ArrayPress\SettingsUtils\Manager;

class MyPlugin {
    private Manager $settings;
    private Register $register;

    public function __construct() {
        $this->settings = new Manager('myplugin_settings');

        // Pass your settings callbacks
        $this->register = new Register(
            'myplugin',
            fn($key, $default = null) => $this->settings->get($key, $default),
            fn($key, $value) => $this->settings->update($key, $value)
        );
    }

    public function activate() {
        // Register pages on plugin activation
        $this->register->add_multiple([
            'checkout' => [
                'title'   => 'Checkout',
                'content' => '[myplugin_checkout]'
            ],
            'account' => [
                'title'   => 'My Account',
                'content' => '[myplugin_account]'
            ],
            'success' => [
                'title'   => 'Thank You',
                'content' => 'Your order has been received!'
            ]
        ]);

        $this->register->install();
    }
}
```

Storage Format
--------------

[](#storage-format)

Pages are stored in a format compatible with settings managers and select fields:

```
// Stored as:
[
    'value' => 123,        // Page ID
    'label' => 'Checkout'  // Page title
]

// This works perfectly with select fields in settings:
$settings->get('checkout_page'); // Returns 123 (the ID)
```

Complete Example with Page Utils
--------------------------------

[](#complete-example-with-page-utils)

Using both Register and Pages (detection) together:

```
use ArrayPress\PageUtils\Register;
use ArrayPress\PageUtils\Pages;
use ArrayPress\SettingsUtils\Manager;

class MyShop {
    private Manager $settings;
    private Register $register;
    private Pages $pages;

    public function __construct() {
        // Settings manager
        $this->settings = new Manager('myshop_settings');

        // Page registration (for activation)
        $this->register = new Register(
            'myshop',
            fn($key, $default = null) => $this->settings->get($key, $default),
            fn($key, $value) => $this->settings->update($key, $value)
        );

        // Page detection (for runtime)
        $this->pages = new Pages(
            'myshop',
            fn($key, $default = null) => $this->settings->get($key, $default)
        );

        // Setup page detection
        $this->pages->add('checkout', 'checkout_page', ['myshop_checkout'], [], true);
        $this->pages->add('account', 'account_page', ['myshop_account'], [], true);
        $this->pages->add('success', 'success_page', ['myshop_success'], [], true);
    }

    public function activate() {
        // Create pages on activation
        $this->register->add('checkout', 'Checkout', '[myshop_checkout]');
        $this->register->add('account', 'My Account', '[myshop_account]');
        $this->register->add('success', 'Order Complete', 'Thank you!');

        $this->register->install();
    }

    public function init() {
        // Use page detection at runtime
        if ($this->pages->is('checkout')) {
            // Load checkout scripts
        }

        // Get URLs
        $checkout_url = $this->pages->get_url('checkout');
    }
}
```

All Methods
-----------

[](#all-methods)

```
// Add a single page
$register->add('key', 'Page Title', 'Page content', $parent_id);

// Add multiple pages
$register->add_multiple([
    'checkout' => ['title' => 'Checkout', 'content' => '[shortcode]'],
    'account'  => ['title' => 'Account', 'content' => '[shortcode]']
]);

// Install/create pages
$page_ids = $register->install();

// Get a page ID
$id = $register->get_page_id('checkout');

// Get a page URL
$url = $register->get_page_url('checkout');

// Check if page exists
if ($register->page_exists('checkout')) {
    // Page exists
}

// Delete a page
$register->delete_page('checkout', true); // true = skip trash

// Get all page IDs
$all_ids = $register->get_page_ids();

// Quick one-liner
$ids = Register::quick_install($pages, 'myplugin', $get_callback, $update_callback);
```

Default WordPress Options
-------------------------

[](#default-wordpress-options)

If you don't use a custom settings manager, it works with standard WordPress options:

```
// Without callbacks - uses get_option/update_option
$register = new Register('myplugin');
$register->add('checkout', 'Checkout', '[checkout_form]');
$register->install();

// Stores as: myplugin_checkout_page => ['value' => 123, 'label' => 'Checkout']
```

Real World Usage
----------------

[](#real-world-usage)

```
// In your main plugin file
register_activation_hook(__FILE__, function() {
    $pages = [
        'shop'     => ['title' => 'Shop',     'content' => '[product_grid]'],
        'cart'     => ['title' => 'Cart',     'content' => '[shopping_cart]'],
        'checkout' => ['title' => 'Checkout', 'content' => '[checkout_form]'],
        'account'  => ['title' => 'Account',  'content' => '[user_account]'],
        'success'  => ['title' => 'Success',  'content' => 'Order complete!']
    ];

    Register::quick_install($pages, 'myshop');
});
```

Key Features
------------

[](#key-features)

- **Simple API** - Just `add()` and `install()`
- **Settings Manager Compatible** - Stores as `['value' => id, 'label' => title]`
- **Works with Page Utils** - Same prefix system for seamless integration
- **Custom Storage** - Use your own get/update callbacks
- **No Over-Engineering** - No MD5 hashes, no complex tracking, just simple page creation

License
-------

[](#license)

GPL-2.0-or-later

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance48

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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/cd6eb8aff0903d87eb674d1ba3c5f3653899c0d7661504eb0deb7798ed86b643?d=identicon)[arraypress](/maintainers/arraypress)

---

Top Contributors

[![arraypress](https://avatars.githubusercontent.com/u/22668877?v=4)](https://github.com/arraypress "arraypress (14 commits)")

### Embed Badge

![Health badge](/badges/arraypress-wp-register-pages/health.svg)

```
[![Health](https://phpackages.com/badges/arraypress-wp-register-pages/health.svg)](https://phpackages.com/packages/arraypress-wp-register-pages)
```

###  Alternatives

[chrismcmacken/phptools

Small utilities that assist in developing applications

253.6k](/packages/chrismcmacken-phptools)

PHPackages © 2026

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