SuperCPT
UPGRADE NOTICE SuperCPT now uses Font Awesome instead of Glyphicons. Some icon names will carry over, but not all. If this is a considerable inconvenience for you for a project, simply do not update it. It’s not a security release, so updating isn’t necessary. Overview SuperCPT is an object wrapper
About this tool.
UPGRADE NOTICE
SuperCPT now uses Font Awesome instead of Glyphicons. Some icon names will carry over, but not all. If this is a considerable inconvenience for you for a project, simply do not update it. It’s not a security release, so updating isn’t necessary.
Overview
SuperCPT is an object wrapper for Custom Post Types, Custom Taxonomies, and Custom Post Meta “for coders, by coders.” Simply put, SuperCPT:
- DRYs up the Custom Post Type and Custom Taxonomy process (e.g. automatically adds the name to all the labels),
- allows you to set default options for all your Custom Post Types and Taxonomies,
- significantly simplifies the process of creating, saving, and displaying Custom Post Meta,
- is sexy! Your custom fields are styled to look great and SuperCPT comes with 361 awesome icons courtesy of Font Awesome .
Demo Video
TextMate/Sublime Text 2 Bundle
If you use TextMate, Sublime Text 2, or another editor which supports TextMate bundles, check out this set of snippets to turbo-charge your development.
And more…
See the Other Notes tab for instructions and demo code. Find more demos and a full reference at GitHub .
Since you’re a hard-core coder, check this out on GitHub if you want to contribute!
Instructions
Depending on when and where you’re declaring your Custom Post Types and Taxonomies, you have different options for which action to hook onto. after_setup_theme is the safest bet, but if you’re referencing this in another plugin, plugins_loaded is a good choice. To avoid a fatal error if something goes awry, you should check to see if the class Super_Custom_Post_Type exists before referencing it. Don’t worry about keeping up, reference code is below.
Custom Post Types
To define a new Custom Post Type, instantiate the Super_Custom_Post_Type class with a string for the post type. For example,
$movies = new Super_Custom_Post_Type( 'movie' );
It works very much like register_post_type . The first thing you gained by using this is that the labels all got setup with either ‘Movie’ or ‘Movies’. If our post type were ‘indie-film’, the labels would have “Indie Film” and “Indie Films” as appropriate. Of course, you do have the ability to set the plural word in cases such as goose/geese. You also gained the ability to define your own custom post type defaults through a filter. Lastly, you gained access to Super_Custom_Post_Type ‘s parent class, Super_Custom_Post_Meta , for fast, clean, intuitive custom post meta, which we’ll go into shortly.