2017 © Pedro Peláez
 

wordpress-muplugin models

WordPress plugin to create custom post types and taxonomies using JSON, YAML or PHP files.

image

soberwp/models

WordPress plugin to create custom post types and taxonomies using JSON, YAML or PHP files.

  • Wednesday, July 25, 2018
  • by soberwp
  • Repository
  • 12 Watchers
  • 88 Stars
  • 5,977 Installations
  • PHP
  • 1 Dependents
  • 1 Suggesters
  • 9 Forks
  • 0 Open issues
  • 13 Versions
  • 20 % Grown

The README.md

Models

Models is a WordPress plugin allowing you to create custom post types and taxonomies using JSON, YAML or PHP files., (*1)

You can now set post types and taxonomies using Intervention 2.x.x., (*2)

Installation

Composer:

Recommended methods:, (*3)

Roots Bedrock, (*4)

$ composer require soberwp/models:1.1.0

Models is a mu-plugin so it doesn't have to be activated., (*5)

Roots Sage, (*6)

$ composer require soberwp/models:1.1.0-p

Manual:

  • Download the zip file
  • Unzip to your sites plugin folder
  • Activate via WordPress

Requirements:

Setup

By default, create folder models/ within the active theme directory., (*7)

If you are a Roots Sage the default folder is app/models/, (*8)

Alternatively, you can define a custom path using the filter below within your themes functions.php file:, (*9)

add_filter('sober/models/path', function () {
    return get_stylesheet_directory() . '/your-custom-folder';
});

That's it, now go ahead and add model-name.json files, in the folder or subfolders to begin creating your models. Use Unravel to automatically move the config files outside of your theme path for better separation of concerns., (*10)

Usage

The data structure follows a similar data structure to WordPress taxonomies and post types arrays, so if an config option is missing from the examples below, follow the developer's reference and place it within "config": {}, (*11)

If values are not specified, defaults are the same as WordPress defaults., (*12)

Additionally, if the Extended CPTs library is available, Models will use it when registering your post types and taxonomies instead allowing extended functionality within your Models., (*13)

Extracted examples presented below are in JSON format., (*14)

Post Types

Create a custom post type., (*15)

Required:

{
  "type": "post-type",
  "name": "book"
}

Basic:

{
  "type": "cpt",
  "name": "book",
  "supports": [
    "title", "editor", "thumbnail"
  ],
  "labels": {
    "has_one": "Book",
    "has_many": "Books",
    "text_domain": "sage"
  }
}

In the above example, "labels": {} are redundant because "Book" and "Books" would have been generated from "name"., (*16)

Multiple:

[
  {
    "type": "cpt",
    "name": "book",
    "supports": [
      "title", "editor", "thumbnail"
    ]
  },
  {
    "type": "cpt",
    "name": "album",
    "supports": [
      "title", "editor", "comments"
    ]
  }
]

All Fields:

Post Type Tips:

  • "active": false stops the post type from being created. Default is set to true.
  • "type": "post-type" also accepts a shorthand "type": "cpt";

Taxonomies

Create a custom taxonomy., (*17)

Required:

{
  "type": "taxonomy",
  "name": "genre"
}

Basic:

{
  "type": "tax",
  "name": "genre",
  "links": [
    "post", "book"
  ],
  "labels": {
    "has_one": "Book Genre",
    "has_many": "Book Genres",
    "text_domain": "sage"
  }
}

"links": (string|array) assigns the taxonomy to post types. Defaults to "links": "post", (*18)

Multiple:

[
  {
    "type": "category",
    "name": "genre",
    "links": "book"
  },
  {
    "type": "tag",
    "name": "author",
    "links": "book"
  }
]

"type": "category" and "type": "tag" shorthands are explained below under Tips., (*19)

All Fields:

Taxonomy Tips:

  • "active": false stops the taxonomy from being created. Default is set to true.
  • "type": "taxonomy" also accepts shorthands;
    • "type": "tax"
    • "type": "category" or "type": "cat" creates a category taxonomy.
    • "type": "tag" creates a tag taxonomy.

Support

Updates

Composer:

  • Change the composer.json version to ^1.0.4**
  • Check CHANGELOG.md for any breaking changes before updating.
$ composer update

WordPress:

Includes support for github-updater to keep track on updates through the WordPress backend. * Download github-updater * Clone github-updater to your sites plugins/ folder * Activate via WordPress, (*20)

The Versions

25/07 2018

dev-master

9999999-dev https://github.com/soberwp

WordPress plugin to create custom post types and taxonomies using JSON, YAML or PHP files.

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress

29/01 2018

1.0.6-p

1.0.6.0-patch https://github.com/soberwp

WordPress plugin to create custom post types and taxonomies using JSON, YAML or PHP files.

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress

29/01 2018

1.0.6

1.0.6.0 https://github.com/soberwp

WordPress plugin to create custom post types and taxonomies using JSON, YAML or PHP files.

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress

28/01 2018

dev-package

dev-package https://github.com/soberwp

WordPress plugin to create custom post types and taxonomies using JSON, YAML or PHP files.

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress

28/01 2018

1.0.7-p

1.0.7.0-patch https://github.com/soberwp

WordPress plugin to create custom post types and taxonomies using JSON, YAML or PHP files.

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress

28/01 2018

1.0.7

1.0.7.0 https://github.com/soberwp

WordPress plugin to create custom post types and taxonomies using JSON, YAML or PHP files.

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress

27/08 2017

1.0.5-p

1.0.5.0-patch https://github.com/soberwp

WordPress plugin to create custom post types and taxonomies using JSON, YAML or PHP files.

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress

27/08 2017

1.0.5

1.0.5.0 https://github.com/soberwp

WordPress plugin to create custom post types and taxonomies using JSON, YAML or PHP files.

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress

11/03 2017

1.0.4

1.0.4.0 https://github.com/soberwp

WordPress plugin to create custom post types and taxonomies using JSON, YAML or PHP files.

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress

06/02 2017

1.0.3

1.0.3.0 https://github.com/soberwp

Simple WordPress plugin to create custom post types and taxonomies using JSON files.

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress

06/01 2017

1.0.2

1.0.2.0 https://github.com/soberwp

Simple WordPress plugin to create custom post types and taxonomies using JSON files.

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress

05/01 2017

1.0.1

1.0.1.0 https://github.com/soberwp

Simple WordPress plugin to create custom post types and taxonomies using JSON files.

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress

03/01 2017

1.0.0

1.0.0.0 https://github.com/soberwp

Simple WordPress plugin to create custom post types and taxonomies using JSON files.

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress