PHPackages                             martinsluters/wpregistrars - 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. martinsluters/wpregistrars

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

martinsluters/wpregistrars
==========================

A library that allows to register WordPress post types and taxonomies in bulk.

0.1.0(4y ago)34GPL-2.0+PHPPHP ^7.4 || ^8.0

Since Jan 30Pushed 4y ago1 watchersCompare

[ Source](https://github.com/martinsluters/wpregistrars)[ Packagist](https://packagist.org/packages/martinsluters/wpregistrars)[ RSS](/packages/martinsluters-wpregistrars/feed)WikiDiscussions develop Synced today

READMEChangelog (1)Dependencies (14)Versions (3)Used By (0)

WP Registrars
=============

[](#wp-registrars)

Introduction
------------

[](#introduction)

In a nutshell the WP Registrars is a small PHP library which allows to register WordPress post types and taxonomies in bulk. Labels are made in plural form and uppercase where required to make development faster.

Minimum Requirements
--------------------

[](#minimum-requirements)

- **PHP:** 7.4
    - PHP 8.0 and 8.1 are supported
- **WordPress:** Tested up to WP 5.9

Installation
------------

[](#installation)

You can install the WP Registrars with composer:

```
composer require martinsluters/wpregistrars

```

Usage
-----

[](#usage)

It is relatively easy to use the library, you can use factories `martinsluters\WPRegistrars\Factories\BulkRegistrarPostTypesFactory` and `martinsluters\WPRegistrars\Factories\BulkRegistrarTaxonomiesFactory`to create new `martinsluters\WPRegistrars\Registrars\BulkRegistrarPostTypes` and `martinsluters\WPRegistrars\Registrars\BulkRegistrarTaxonomies` registrar instances.

```
use martinsluters\WPRegistrars\Factories\{ BulkRegistrarPostTypesFactory, BulkRegistrarTaxonomiesFactory };

( new  BulkRegistrarPostTypesFactory() )
    ->withArguments( [ 'report', 'guide', 'resource' ] )
    ->create()
    ->register();

( new  BulkRegistrarTaxonomiesFactory() )
    ->withArguments(
    	[
		'resource_type' => [ 'object_type' => [ 'resource' ] ]
		'guide_language' => [ 'object_type' => [ 'guide' ] ]
		'my-random-taxonomy'
    	]
    )
    ->create()
    ->register();
```

Note: This documentation will not cover the appropriate place and time in WordPress action execution order to use the library.

Hint: Post type and taxonomy registrations should not be hooked before the [‘init’](https://developer.wordpress.org/reference/hooks/init/) action.

Usage of factory build methods
------------------------------

[](#usage-of-factory-build-methods)

### withArguments( array $arguments )

[](#witharguments-array--arguments-)

It is mandatory to use this method to register custom post type or custom taxonomy. At the most minimal configuration it requires an indexed array passed with at least one element with a string type value. `withArguments( [ 'report' ] )` The string is considered as the post type or taxonomy key. You can pass in theory an unlimited number of elements.

It is possible to pass additional registration arguments. By setting an array element with a string type key (to be considered as post type or taxonomy key) and array type element value. Array passed to the value is what you would normally pass when registering a post type and taxonomy. `withArguments( [ 'report' => [ 'public' => true ] ] )`

To pass object type(s) when registering a taxonomy use the following `withArguments( [ 'guide_language' => [ 'object_type' => [ 'guide', 'report' ] ] ] )`

Arguments passed to [withArguments](https://stackedit.io/app#witharguments-array--arguments-) takes over arguments passed to [withDefaultRegistrationArguments](https://stackedit.io/app#withdefaultregistrationarguments-array--default_registration_arguments-).

### withDefaultRegistrationArguments( array $default\_registration\_arguments )

[](#withdefaultregistrationarguments-array--default_registration_arguments-)

It is possible to set default registration arguments that will be applied to all post types or taxonomies. Array passed is what you would normally pass when registering a post type and taxonomy.

```
withDefaultRegistrationArguments( [ 'public' => true ] )

```

An exception is passing taxonomy registration object type(s). You can pass them along with registration arguments array using the following format

```
withDefaultRegistrationArguments( [ 'object_type' => [ 'guide', 'report' ] ] )

```

Arguments passed to [withArguments](#witharguments-array--arguments-) takes over arguments passed to [withDefaultRegistrationArguments](#withdefaultregistrationarguments-array--default_registration_arguments-).

### shouldAutoPluralize( bool $should\_auto\_pluralize\_label )

[](#shouldautopluralize-bool--should_auto_pluralize_label-)

By default labels of post type or taxonomy are made in plural form where it is required using post type or taxonomy key as source. It is possible to disable the feature using `shouldAutoPluralize( false ) `. If `withDefaultRegistrationArguments` or `withArguments` provides array element `label` then `shouldAutoPluralize` has no effect.

### withPluralizer( PluralizerInterface $pluralizer )

[](#withpluralizer-pluralizerinterface--pluralizer-)

By default labels of post type and taxonomy are made in plural English form using `Doctrine\Inflector\Inflector` that is a dependency for the library. It is possible to change the language used by providing a different language using `Doctrine\Inflector\Language`

```
use martinsluters\WPRegistrars\Factories\BulkRegistrarPostTypesFactory;
use martinsluters\WPRegistrars\PluralizerDoctrineInflectorAdapter;
use Doctrine\Inflector\{ InflectorFactory, Inflector, Language };

$doctrine_inflector_spanish = ( new InflectorFactory( Language::SPANISH ) )
	->create()
	->build();
$pluralizer_spanish = new PluralizerDoctrineInflectorAdapter( $doctrine_inflector_spanish );

( new BulkRegistrarPostTypesFactory() )
	->withPluralizer( $pluralizer_spanish )
	->withDefaultRegistrationArguments( ['public' => true] )
	->withArguments( [ 'escuela' ] )
	->create()
	->register();
```

Note: Please see the official documentation of `Doctrine\Inflector` to find the supported languages.

**You can use a different tool to make words in a plural form and disregard `Doctrine\Inflector` completely. To do so you must provide to `withPluralizer` an adapter that implements `martinsluters\WPRegistrars\PluralizerInterface`.**

### shouldAutoCapitalize( bool $should\_auto\_capitalize\_label )

[](#shouldautocapitalize-bool--should_auto_capitalize_label-)

By default labels of post type or taxonomy are made in a way that first character of each word in `string` is capitalized, if that character is alphabetic. The source of label is post type or taxonomy key. It is possible to disable the feature using `shouldAutoCapitalize( false )`. If `withDefaultRegistrationArguments` or `withArguments` provides array element `label` then `shouldAutoCapitalize` has no effect.

### create()

[](#create)

Creates registrar instance if it is possible.

Usage of registrar methods
--------------------------

[](#usage-of-registrar-methods)

### register()

[](#register)

Registers either post types or taxonomies.

License
-------

[](#license)

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1614d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18058037?v=4)[Martins Luters](/maintainers/martinsluters)[@martinsluters](https://github.com/martinsluters)

---

Top Contributors

[![martinsluters](https://avatars.githubusercontent.com/u/18058037?v=4)](https://github.com/martinsluters "martinsluters (2 commits)")

---

Tags

registertaxonomybulkpost type

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/martinsluters-wpregistrars/health.svg)

```
[![Health](https://phpackages.com/badges/martinsluters-wpregistrars/health.svg)](https://phpackages.com/packages/martinsluters-wpregistrars)
```

###  Alternatives

[illuminate/support

The Illuminate Support package.

630113.0M41.0k](/packages/illuminate-support)[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k51.2M335](/packages/api-platform-core)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k14](/packages/tempest-framework)[api-platform/metadata

API Resource-oriented metadata attributes and factories

275.0M215](/packages/api-platform-metadata)[sonata-project/classification-bundle

Symfony SonataClassificationBundle

953.2M21](/packages/sonata-project-classification-bundle)[aliziodev/laravel-taxonomy

Laravel Taxonomy is a flexible and powerful package for managing taxonomies, categories, tags, and hierarchical structures in Laravel applications. Features nested-set support for optimal query performance on hierarchical data structures.

24426.4k](/packages/aliziodev-laravel-taxonomy)

PHPackages © 2026

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