Last active
August 29, 2015 14:23
-
-
Save kjohnson/5dbadbaf584a51032a4f to your computer and use it in GitHub Desktop.
An example CPT with the Ninja Forms Append A Form met box.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CPT_Example { | |
| public function __construct() { | |
| add_action( 'init', array( $this, 'custom_post_type' ), 0 ); | |
| add_action('add_meta_boxes', array( $this, 'ninja_forms_add_custom_box' ) ); | |
| } | |
| public function custom_post_type() { | |
| //Source: http://generatewp.com/post-type/ | |
| $labels = array( | |
| 'name' => _x( 'Examples', 'Post Type General Name', 'text_domain' ), | |
| 'singular_name' => _x( 'Post Example', 'Post Type Singular Name', 'text_domain' ), | |
| 'menu_name' => __( 'Example CPT', 'text_domain' ), | |
| 'name_admin_bar' => __( 'Example CPT', 'text_domain' ), | |
| 'parent_item_colon' => __( 'Parent Item:', 'text_domain' ), | |
| 'all_items' => __( 'All Items', 'text_domain' ), | |
| 'add_new_item' => __( 'Add New Item', 'text_domain' ), | |
| 'add_new' => __( 'Add New', 'text_domain' ), | |
| 'new_item' => __( 'New Item', 'text_domain' ), | |
| 'edit_item' => __( 'Edit Item', 'text_domain' ), | |
| 'update_item' => __( 'Update Item', 'text_domain' ), | |
| 'view_item' => __( 'View Item', 'text_domain' ), | |
| 'search_items' => __( 'Search Item', 'text_domain' ), | |
| 'not_found' => __( 'Not found', 'text_domain' ), | |
| 'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ), | |
| ); | |
| $args = array( | |
| 'label' => __( 'example', 'text_domain' ), | |
| 'description' => __( 'Example Custom Post Type', 'text_domain' ), | |
| 'labels' => $labels, | |
| 'supports' => array( 'title', 'editor', ), | |
| 'hierarchical' => false, | |
| 'public' => true, | |
| 'show_ui' => true, | |
| 'show_in_menu' => true, | |
| 'menu_position' => 5, | |
| 'show_in_admin_bar' => true, | |
| 'show_in_nav_menus' => true, | |
| 'can_export' => true, | |
| 'has_archive' => true, | |
| 'exclude_from_search' => false, | |
| 'publicly_queryable' => true, | |
| 'capability_type' => 'page', | |
| ); | |
| register_post_type( 'example', $args ); | |
| } | |
| function ninja_forms_add_custom_box() { | |
| add_meta_box( | |
| 'ninja_forms_selector', | |
| __( 'Append A Ninja Form', 'ninja-forms'), | |
| 'ninja_forms_inner_custom_box', | |
| 'example', //Custom Post Type | |
| 'side', | |
| 'low' | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment