Giter Site home page Giter Site logo

wp-admin-utility's Introduction

WordPress Admin Page Utility

wp-admin-utility installs as a plugin and provides an API for quickly setting up custom post types and options pages. Whereas other post type builders provide an admin interface for creating post types, this utility reads static configuration files to create post types via a declarative syntax.

Installation

composer require dwalkr/wp-admin-utility

Basic Usage

The PageCreator singleton is used to parse configuration files. It is made available on a custom hook named adminutility-pagecreator-init. The hook is triggered on after_setup_theme, so just be sure you add your callback before that event (plugins can use plugins_loaded and themes can just put their code directly in functions.php.)

Use the addPostType method to create post types, and addSettingsPage to create options pages.

<?php

add_action('adminutility-pagecreator-init', function($pageCreator){
  $pageCreator->addPostType('/path/to/config.yml');
});

Configuration Formats

Configuration files can be in yaml, json, or php format. When passing a PHP file to PageCreator, the file should return the configuration as an associative array.

Direct Array/Object Config

Instead of having PageCreator parse a configuration file, you can pass an array or PHP object containing the configuration instead of the path to a file. Use the FROM_ARRAY and FROM_OBJECT constants to tell PageCreator how to process the first method parameter.

<?php

$config = [
  'active' => true,
  'name' => 'specials',
  'public' => true
  //...
];
$pageCreator->addPostType($config, \dwalkr\WPAdminUtility\PageCreator::FROM_ARRAY);

Configuration API

Almost all options that can be passed into the register_post_type function can be added to the top-level config for a post type.

To understand how to set up meta boxes with custom fields, see the post type example.

To understand how to set up settings pages, see the settings page example.

Adding Custom Meta Boxes to Existing Post Types

To add a custom fields and meta boxes to an existing post type, just add a configuration file with the name property matching the existing post type. If the post type has already been registered, the rest of the top-level configuration is ignored and only metaboxes are added.

wp-admin-utility's People

Contributors

briandukes avatar d3briand avatar dwalkr avatar xachman avatar zid3 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

wp-admin-utility's Issues

date format

date format option isn't being used

allow custom date format to be used in calendar

always format as Y-m-d (H:i:s) on save regardless of format param

option to save only id for attachment field type

This really should be the default behavior but 'include_id' parameter was added instead for backward compatibility.

We could add as an api_version upgrade and make it default behavior when api_version == 0.2

PostTaxonomy::register function allows spaced name to be passed into register_taxonomy

When a spaced name is passed into register_taxonomy the function allows it but then all the javascript breaks that allow adding taxonomies in the admin. This can be avoided by using labels and changing the name to a none spaced value however since we use the name to generate labels if labels are not included it may be a good idea to string to lower and replace the spaces with underscores in the name value.

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.