Coder Social home page Coder Social logo

serve-the-base's Introduction

Serve The Base β›„

Serve The Base is a WordPress parent theme that allows for rapid and highly-customized REST API creation. It parses a JSON file in your child theme and generates all of your custom post types, taxonomies, and meta fields for you.

STB is designed to be completely front-end agnostic. You can build a full front-end in your child theme, or you can use your WordPress site as the backend for a fully decoupled CMS.

What It Does ⚑

STB will register all custom post types, taxonomies, and fields specified in the schema file. It will create all necessary REST endpoint as well as include data from your custom fields as part of responses.

STB makes absolutely no decisions about the front-end of your site. If you try using STB as a parent theme, it will yell at you.

Getting Started πŸ”₯

  • Download a zip of the theme and install it like normal
  • cd to the theme directory and run composer install – this assumes you have composer itself installed
  • Make a new directory in your theme directory – this will be your child theme. In this theme, create two files: functions.php and style.css. In style.css add the following:
/*
Theme Name: <your theme name>
Template: <directory where STB installed>
*/
  • Create a file named schema.json in your child theme. You can start with the contents of schema-sample.json in this repo, or start from scratch

Schema.json πŸ“

A sample schema.json file is provided with this project that can be used as a reference. Your file should look something like this:

{
  "types": [
    { 
      "name":      string | required
      "plural":    string | optional – provide only for non-standard pluralizations (e.g. "radii", "children")
      "supports":  array<string> | optional – used as "supports" argument when registering CPT
      "args":      object | optional – non-default args to be used when registering CPT
    }
  ],
  "taxonomies: [
    {
      "name":      string | required
      "plural":    string | optional – provide for non-standard pluralizations
      "describes": array<string>|string | optional – post type(s) that the taxonomy will be associated with. default "post"
      "args":      object | optional – non-default args to be used when registering custom taxonomy
    }
  ],
  "field_groups: [
    {
      "name":        string | required
      "belongs_to":  array<string>|string|"all" – post type(s) that the field group will belong to. default "post"
      "fields": {    array<object> | required
        {
          "name":    string | required 
          "type":    string | optional – defaults to "text_small"
          "options": array<string> | optional
        }
      }
    }
  ]
}

Referring to the documentation for registering custom post types, custom taxonomies, and CMB2 fields may be helpful.

On the radar πŸ‘€

This project is in a production-ready state, but I'll keep it maintained should anything in WordPress core or in CMB2 change. If anyone wants to put together a fork which works with ACF, go for it!

Thanks 😘

This project wouldn't be possible without CMB2.

serve-the-base's People

Contributors

ethanbutler avatar

Watchers

James Cloos avatar Lee Peterson 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.