• Stars
    star
    971
  • Rank 46,976 (Top 1.0 %)
  • Language
    PHP
  • License
    GNU General Publi...
  • Created over 11 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A library which provides extended functionality to WordPress custom post types and taxonomies.

Build Status Stable Release License PHP 7 and 8 Documentation

Extended CPTs

Extended CPTs is a library which provides extended functionality to WordPress custom post types and taxonomies. This allows developers to quickly build post types and taxonomies without having to write the same code again and again.

Extended CPTs works with both the block editor and the classic editor.

See the wiki for full documentation.

Not your first time here? See Recent Changes for Developers to see what features are new in recent versions of Extended CPTs.

Improved Defaults for Post Types

  • Automatically generated labels and post updated messages (in English)
  • Public post type with admin UI and post thumbnails enabled
  • Hierarchical with page capability type
  • Optimal admin menu placement

Improved Defaults for Taxonomies

  • Automatically generated labels and term updated messages (in English)
  • Hierarchical public taxonomy with admin UI enabled

Extended Admin Features

  • Declarative creation of table columns on the post type listing screen:
    • Columns for post meta, taxonomy terms, featured images, post fields, Posts 2 Posts connections, and custom functions
    • Sortable columns for post meta, taxonomy terms, and post fields
    • User capability restrictions
    • Default sort column and sort order
  • Declarative creation of table columns on the taxonomy term listing screen:
    • Columns for term meta and custom functions
    • User capability restrictions
  • Filter controls on the post type listing screen to enable filtering posts by post meta, taxonomy terms, post author, and post dates
  • Override the 'Featured Image' and 'Enter title here' text
  • Several custom meta boxes available for taxonomies on the post editing screen:
    • Simplified list of checkboxes
    • Radio buttons
    • Dropdown menu
    • Custom function
  • Post types and taxonomies automatically added to the 'At a Glance' section on the dashboard
  • Post types optionally added to the 'Recently Published' section on the dashboard

Extended Front-end Features for Post Types

  • Specify a custom permalink structure:
    • For example reviews/%year%/%month%/%review%
    • Supports all relevant rewrite tags including dates and custom taxonomies
    • Automatic integration with the Rewrite Rule Testing plugin
  • Specify public query vars which enable filtering by post meta and post dates
  • Specify public query vars which enable sorting by post meta, taxonomy terms, and post fields
  • Override default public or private query vars such as posts_per_page, orderby, order, and nopaging
  • Add the post type to the site's main RSS feed

Minimum Requirements

  • PHP: 7.4
    • Tested up to PHP 8.2
  • WordPress: 5.6
    • Tested up to WP 6.2

Installation

Extended CPTs is a developer library, not a plugin, which means you need to include it as a dependency in your project. Install it using Composer:

composer require johnbillion/extended-cpts

Other means of installation or usage, particularly bundling within a plugin, is not officially supported and done at your own risk.

Usage

Need a simple post type with no frills? You can register a post type with a single parameter:

add_action( 'init', function() {
	register_extended_post_type( 'article' );
} );

And you can register a taxonomy with just two parameters:

add_action( 'init', function() {
	register_extended_taxonomy( 'location', 'article' );
} );

Try it. You'll have a hierarchical public post type with an admin UI, a hierarchical public taxonomy with an admin UI, and all the labels and updated messages for them will be automatically generated.

Or for a bit more functionality:

add_action( 'init', function() {
	register_extended_post_type( 'story', [

		# Add the post type to the site's main RSS feed:
		'show_in_feed' => true,

		# Show all posts on the post type archive:
		'archive' => [
			'nopaging' => true,
		],

		# Add some custom columns to the admin screen:
		'admin_cols' => [
			'story_featured_image' => [
				'title'          => 'Illustration',
				'featured_image' => 'thumbnail'
			],
			'story_published' => [
				'title_icon'  => 'dashicons-calendar-alt',
				'meta_key'    => 'published_date',
				'date_format' => 'd/m/Y'
			],
			'story_genre' => [
				'taxonomy' => 'genre'
			],
		],

		# Add some dropdown filters to the admin screen:
		'admin_filters' => [
			'story_genre' => [
				'taxonomy' => 'genre'
			],
			'story_rating' => [
				'meta_key' => 'star_rating',
			],
		],

	], [

		# Override the base names used for labels:
		'singular' => 'Story',
		'plural'   => 'Stories',
		'slug'     => 'stories',

	] );

	register_extended_taxonomy( 'genre', 'story', [

		# Use radio buttons in the meta box for this taxonomy on the post editing screen:
		'meta_box' => 'radio',

		# Add a custom column to the admin screen:
		'admin_cols' => [
			'updated' => [
				'title_cb'    => function() {
					return '<em>Last</em> Updated';
				},
				'meta_key'    => 'updated_date',
				'date_format' => 'd/m/Y'
			],
		],

	] );
} );

Bam, we now have:

  • A 'Stories' post type, with correctly generated labels and post updated messages, three custom columns in the admin area (two of which are sortable), stories added to the main RSS feed, and all stories displayed on the post type archive.
  • A 'Genre' taxonomy attached to the 'Stories' post type, with correctly generated labels and term updated messages, and a custom column in the admin area.

The register_extended_post_type() and register_extended_taxonomy() functions are ultimately wrappers for the register_post_type() and register_taxonomy() functions in WordPress core, so any of the parameters from those functions can be used.

There's quite a bit more you can do. See the wiki for full documentation.

Contributing and Testing

Please see CONTRIBUTING.md for information on contributing.

License: GPLv2 or later

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.

More Repositories

1

query-monitor

The developer tools panel for WordPress
PHP
1,580
star
2

wp_mail

Documentation for all the situations where WordPress core sends an email, how and when they happen, and how to filter or disable each one.
344
star
3

wp-crontrol

Take control of the cron events on your WordPress website
PHP
208
star
4

user-switching

WordPress plugin that provides instant switching between user accounts.
PHP
185
star
5

wp-json-schemas

JSON schemas for WordPress PHP objects and REST API responses
TypeScript
139
star
6

extended-template-parts

A library which provides extended functionality to WordPress template parts, including template variables and caching.
PHP
114
star
7

args

Array arguments made bearable
PHP
107
star
8

extended-taxos

PHP
100
star
9

ext

WP-CLI command which checks the existence of PHP extensions needed to run WordPress.
PHP
71
star
10

wp-types

TypeScript definitions for WordPress PHP objects and REST API responses
27
star
11

php-docs-standards

PHPUnit tests for documentation standards of PHP functions and methods.
PHP
24
star
12

wordpress-keyboard-shortcuts

A WordPress plugin which adds keyboard shortcuts for navigation and actions
PHP
23
star
13

wordpress-x

The most powerful and smartest admin toolbar ever in a CMS.
PHP
18
star
14

probot-semver

A GitHub app that provides automatic semantic versioning support
JavaScript
15
star
15

plugin-infrastructure

Reusable infrastructure relating to testing, building, and deploying my WordPress plugins
Shell
13
star
16

user-switching-for-regular-admins

Adds support to the User Switching plugin for regular admins on multisite
PHP
11
star
17

vip-go-indicator

Adds an admin toolbar indicator which identifies the current WordPress.com VIP Go environment
PHP
9
star
18

ideas

Ideas for things that I'll build just as soon as I find the time
8
star
19

global-post-password

WordPress plugin to globally set a password for all password protected posts and pages
PHP
8
star
20

revisions-digest

A WordPress plugin which generates digests of changes to content via their revisions.
PHP
7
star
21

plugin-info

Provides a simple way of displaying up-to-date information about specific WordPress Plugin Directory hosted plugins in your blog posts and pages.
PHP
7
star
22

falsey-assertequals-detector

Marks a PHPUnit test as risky if it tests a falsey value with assertEquals()
PHP
7
star
23

wp-git-status

WordPress plugin that shows the Git branch and current status in the admin toolbar
PHP
6
star
24

extended-widgets

PHP
5
star
25

wctrn-login-lockdown

Login Lockdown plugin for the WordCamp Torino 2018 WP-CLI workshop
PHP
4
star
26

wp-stats

HTML
4
star
27

https-indicator

PHP
3
star
28

php-errors

PHP error handling tests
PHP
3
star
29

slurpetta

Slurps down the most popular plugins and themes from WordPress.org
PHP
3
star
30

wp-contributors-map

A Node.js server for generating a GeoJSON file of contributors to WordPress.
JavaScript
3
star
31

wctrn-site-setup-script

Site setup script for the WordCamp Torino 2018 WP-CLI workshop
Shell
3
star
32

user-switching-duo-security

User Switching add-on plugin so it plays nicely with Duo Security
PHP
3
star
33

PrettyFilters

A proof-of-concept WordPress plugin which adds a much nicer interface to the filters on post listing screens
PHP
3
star
34

qm-self-awareness

Self-profiling plugin for Query Monitor.
PHP
3
star
35

gitattributes-globs

Parse a .gitattributes file and return its export-ignore entries as an array of glob patterns.
JavaScript
2
star
36

resource-host-monitor

PHP
1
star
37

ssl-helper

PHP
1
star
38

.github

1
star
39

johnbillion

1
star