Download the PHP package brightnucleus/custom-content without Composer
On this page you can find all versions of the php package brightnucleus/custom-content. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download brightnucleus/custom-content
More information about brightnucleus/custom-content
Files in brightnucleus/custom-content
Package custom-content
Short Description Config-driven WordPress Custom Content Definitions (Custom Post Types, Custom Taxonomies).
License MIT
Informations about the package custom-content
Bright Nucleus Custom Content
Config-driven WordPress Custom Content Definitions (Custom Post Types, Custom Taxonomies).
Table Of Contents
- Installation
- Basic Usage
- Registering A New Custom Post Type
- Registering A New Custom Taxonomy
- Registering Several Custom Content Elements At Once
- About Rewrite Rules
- Contributing
- License
Installation
The best way to use this package is through Composer:
Basic Usage
Registering A New Custom Post Type
To register a new custom post type, you need to define it within a Config file. Default values can be found within config/defaults.php
configuration. You then instantiate the CustomPostType
class by injecting your Config into its constructor, and call its register()
method.
Example:
Registering A New Custom Taxonomy
To register a new custom taxonomy, you need to define it within a Config file. Default values can be found within config/defaults.php
configuration. You then instantiate the CustomTaxonomy
class by injecting your Config into its constructor, and call its register()
method.
Example:
Registering Several Custom Content Elements At Once
To register several custom content elements at once, you can instantiate a CustomContent
object and pass it a Config with all of your custom post types and taxonomies included.
The format of the Config is similar to the singular Configs above, with the distinction that it starts with a key for each type of custom content after the prefix. The different slugs are then children of the corresponding content type.
Known content types are:
CustomPostType
CustomTaxonomy
Example:
About Rewrite Rules
If your custom content includes pretty permalinks, you will need to flush the rewrite rules.
NOTE: You need to take care that you only flush the rewrite rules once, not on every page request.
The best way to achieve this is to hook into plugin activation, register your custom content, and then call flush_rewrite_rules()
from within that hook.
Example:
Contributing
All feedback / bug reports / pull requests are welcome.
License
Copyright (c) 2016 Alain Schlesser, Bright Nucleus
This code is licensed under the MIT License.
All versions of custom-content with dependencies
brightnucleus/config Version >=0.4.3
brightnucleus/contracts Version >=0.1.1
brightnucleus/localization Version >=0.1.0
doctrine/collections Version >=1.3