Dev Docs
  • Disciple.Tools Technical Documentation
  • Theme Core
    • API - Posts
      • List of Endpoints
      • Fields Format
      • Get Post
      • Create Post
      • Update Post
      • Post Comments
      • Post Activity
      • List Query
      • Global Search
      • Posts in Typeaheads
      • Post-Sharing
      • Get Following
      • Settings
    • API - Other
      • Users
      • Locations
      • Settings
    • Hooks
      • Record Page Hooks
      • API-Hooks
      • Public settings
      • Adding menu navigation links
    • Customization
      • Fields
      • Custom Post Types
      • Post Type Modules
      • Adding Fields and Tiles.
    • Authentication
      • JWT-Authentication-for-the-mobile-app
      • Site-to-Site-Link
      • Easy-Example
    • Permissions
    • Roles and Permissions
    • Database Tables
      • Activity Table
    • Disciple.Tools Translation
    • Revisions
      • v1.0.0-dev-changes
      • v1.0
  • Hosting
    • 404 Errors on new install
    • CRON
    • Hosting on WPEngine
    • Backups
    • Single Site or MultiSite
  • Disciple.Tools Development Setup
    • LocalWP
    • Mobile App Setup
    • Unit Tests
    • Cypress Tests
    • D.T on Docker Setup
    • Gulp - CSS and JS
  • Code Contribution
    • Theme Contribution Guidelines
    • How to Correctly Contribute to the Disciple Tools Repository
    • How to Translate Your Plugin
  • Style Guide
  • Disciple.Tools Code of Conduct
Powered by GitBook
On this page
  • Getting The Module List
  • How To Add A Modules
  • Declaring The Module
  • The Module Class

Was this helpful?

Edit on Git
  1. Theme Core
  2. Customization

Post Type Modules

Modules extend the functionality of a post type like Contacts or Groups. A modules can be used to add:

  • Fields

  • Workflows

  • List filters

  • Roles

  • Other functionality

A module resembles what can be done through a plugin. The big difference is the instance admin can enable/disable the modules they want and the theme/plugins can package multiple modules.

With v1.0 the D.T theme has 2 main modules available by default: the DMM module and the Access modules. The DMM adds fields, filters and workflows that go with: coaching, faith milestones, baptism date, baptisms etc. These are fields needed for any DMM. The Access module focuses more on contact followup and come with fields like the seeker path, the assigned_to and subassigned. It also adds our Follow-up filter tab on the lists page.

Getting The Module List

$modules = dt_get_option( "dt_post_type_modules" );
// check if the access module is enabled
if ( empty( $modules["access_module"]["enabled"] ) ){
    return;
}

How To Add A Modules

Declaring The Module

Hook into the dt_post_type_modules filter.

add_filter( 'dt_post_type_modules', function( $modules ){
    $modules["module_key"] = [
        "name" => "Module Name",
        "enabled" => true, // default if the module is enabled. The admin's preference in the settings will take precedence.
        "prerequisites" => [ "dmm_module", "contacts_base" ], //don't load this module unless these other modules are also loaded
        "post_type" => "contacts", //the post type the module extends
        "description" => "Field and workflows for follow-up ministries" //displayed on the wp-admin settings page.
    ];
    return $modules;
}, 20, 1 );

The Module Class

See dt-contacts/access-module.php as an example.

Keep in mind:

  • extend DT_Module_Base.

  • declare the $post_type and $module public variables.

  • call self::check_enabled_and_prerequisites() to only load if:

    • the module is enabled in the settings.

    • the prerequisites are also enabled.

class DT_Contacts_Access extends DT_Module_Base {
    public $post_type = "contacts";
    public $module = "access_module";

    public function __construct(){
        parent::__construct();
        if ( !self::check_enabled_and_prerequisites() ){
            return;
        }
        //your filters
    }

    //your functions
}
PreviousCustom Post TypesNextAdding Fields and Tiles.

Last updated 3 years ago

Was this helpful?