GithubHelp home page GithubHelp logo

theperfectwill / extended-cpts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from johnbillion/extended-cpts

0.0 1.0 0.0 463 KB

A library which provides extended functionality to WordPress custom post types, allowing developers to quickly build custom post types without having to write the same code again and again.

Home Page: http://johnbillion.com/extended-cpts/

License: GNU General Public License v2.0

Shell 3.03% PHP 96.97%

extended-cpts's Introduction

Build Status Coverage Status Stable Release License

Extended CPTs

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

See the wiki for full documentation.

See also: Extended Taxonomies.

Improved defaults

  • Automatically generated labels and post updated messages
  • Public post type with admin UI enabled
  • Hierarchical with page capability type
  • Support for post thumbnails
  • Optimal admin menu placement

Extended admin features

  • Ridiculously easy custom columns on the post type listing screen:
    • Columns for post meta, taxonomy terms, featured images, post fields, Posts 2 Posts connections, and callback functions
    • Sortable columns for post meta, taxonomy terms, and post fields
    • User capability restrictions
    • Default sort column and sort order
  • Filter controls on the post type listing screen to enable filtering by post meta and taxonomy terms
  • Override the 'Featured Image' and 'Enter title here' text
  • Add the post type to the 'At a Glance' section on the dashboard

Extended front-end features

  • 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
  • Specify public query vars which enable sorting by post meta, taxonomy terms, and post fields
  • Override 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: 5.4
WordPress: 4.4

Usage

Extended CPTs is a developer library, not a plugin, which means you need to include it somewhere in your own plugin or theme:

require_once 'extended-cpts/extended-cpts.php';

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

register_extended_post_type( 'article' );

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

register_extended_post_type( 'story', array(

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

	# Show all posts on the post type archive:
	'archive' => array(
		'nopaging' => true
	),

	# Add some custom columns to the admin screen:
	'admin_cols' => array(
		'featured_image' => array(
			'title'          => 'Illustration',
			'featured_image' => 'thumbnail'
		),
		'published' => array(
			'title'       => 'Published',
			'meta_key'    => 'published_date',
			'date_format' => 'd/m/Y'
		),
		'genre' => array(
			'taxonomy' => 'genre'
		)
	),

	# Add a dropdown filter to the admin screen:
	'admin_filters' => array(
		'genre' => array(
			'taxonomy' => 'genre'
		)
	)

), array(

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

) );

Bam, we 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.

The register_extended_post_type() function is ultimately a wrapper for register_post_type(), so any of the latter's parameters 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.

Please see the tests readme for information on running the unit test suite.

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.

extended-cpts's People

Contributors

danielhomer avatar johnbillion avatar simonwheatley avatar spacedmonkey avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.