-
Notifications
You must be signed in to change notification settings - Fork 9
Configuring Sample Post Type
Chris Chasm edited this page Feb 3, 2021
·
8 revisions
Notes on configuring the post type are included in the code with @todo notes. You can review the two sample files here.
The core elements of the post type are defined in the $modules array. Check out extensive documentation here (How To Add A Modules).
$modules["starter_base"] = [
"name" => "Starter",
"enabled" => true,
"locked" => true,
"prerequisites" => [ "contacts_base" ],
"post_type" => "starter_post_type",
"description" => "Default starter functionality"
];
- Name and description are self explanatory. Just update the values.
- Enabled is the default state of the module. This can be changed by an admin in the administrative area.
- Locked means it is required and cannot be disabled.
- post_type is the key for the post type you are creating. It cannot have any spaces or hyphens, and must use underscores, if it is two or more words. Make sure to chose a post type key that is not used by other plugins, i.e. trainings or contacts or groups.
- prerequisites defines what other modules needs to be loaded before this one. 'contacts_base' is a safe prerequisite to use so that all expected dependencies are available.
add_action( 'after_setup_theme', [ $this, 'after_setup_theme' ], 100 ); add_filter( 'dt_set_roles_and_permissions', [ $this, 'dt_set_roles_and_permissions' ], 20, 1 ); //after contacts
//setup tiles and fields
add_action( 'p2p_init', [ $this, 'p2p_init' ] );
add_filter( 'dt_custom_fields_settings', [ $this, 'dt_custom_fields_settings' ], 10, 2 );
add_filter( 'dt_details_additional_tiles', [ $this, 'dt_details_additional_tiles' ], 10, 2 );
add_action( 'dt_details_additional_section', [ $this, 'dt_details_additional_section' ], 20, 2 );
add_action( 'wp_enqueue_scripts', [ $this, 'scripts' ], 99 );
// hooks
add_action( "post_connection_removed", [ $this, "post_connection_removed" ], 10, 4 );
add_action( "post_connection_added", [ $this, "post_connection_added" ], 10, 4 );
add_filter( "dt_post_update_fields", [ $this, "dt_post_update_fields" ], 10, 3 );
add_filter( "dt_post_create_fields", [ $this, "dt_post_create_fields" ], 10, 2 );
add_action( "dt_post_created", [ $this, "dt_post_created" ], 10, 3 );
add_action( "dt_comment_created", [ $this, "dt_comment_created" ], 10, 4 );
//list
add_filter( "dt_user_list_filters", [ $this, "dt_user_list_filters" ], 10, 2 );
add_filter( "dt_filter_access_permissions", [ $this, "dt_filter_access_permissions" ], 20, 2 );
dt_set_roles_and_permissions( $expected_roles )