#YA Content Architecture for WordPress
Helps manage a plugin's content architecture including:
- Custom Post Types
- Custom Taxonomies
- Custom Tables for Custom Content
- Metadata API support for Custom Content. See: Meta for Custom Objects in WordPress
- See
/sample-schema
directory for examples. - Do not change the directory structure.
- Do not edit
/custom-meta/custom-meta.php
. - Add one schema file each (using the sample) for every custom post type in
/post_type/
. - Add one schema file each (using the sample) for every custom taxonomy in
/taxonomy/
. - Add one schema file each (using the sample) for every custom table in
/custom/
. - Create a config file called
config.php
inside the root of the schema directory.
Use the included sample to return an array of all the content types.
<?php
return $architecture = array(
'post_type' => array(
'books',
),
'taxonomy' => array(
'authors' => array('books'), // will be added to books
),
'custom' => array(
// this will add support for Metadata API
'libraries' => array(
'has_meta' => true,
),
'lending' => array(),
),
);
Note
- Under the
custom
index of this array, include each custom table as'table_name' => array()
. - Tables that create custom content objects that need Metadata API support will need a
has_meta
key in the config.
Include the class class-ya-content-architecture.php
in your plugin somewhere.
Parameters
$prefix
to be used for the custom tables.$schema_path
is the path to your schema directory.- Optionally, pass a
$db_version
to save in the options table.
Instantiate
$architecture = new YA_Content_Architecture( '_my_prefix', plugin_dir_path().'/schema/', '0.1.0');
register_activation_hook( __FILE__, array ( $architecture, 'install' ) );
$architecture->init();
Methods
- An
install()
method that'll install/update the custom tables. Can be used in the activation hook. - An
init()
method that registers the post types, taxonomies and support for Metadata API. Just call it, it will automatically hook the appropriate methods to WordPress'sinit
action.