Admin Hook

1. Admin / WordPress Hooks Registered in init()

These hooks connect the contact module with the NextCRM admin menu, enqueue system, AJAX system, activation process, and WordPress user deletion.

HookTypeCode RefPurpose
nextcrm/admin_menu/bottomActionLine 19Registers Contact, Add New, Lists, Tags, and Contact Settings menus.
nextcrm/enqueue/admin/page/dependencyFilterLine 21Adds contact post type pages to the admin enqueue dependency list.
nextcrm/admin/notices/dependencyFilterLine 27Adds contact post type to the admin notices dependency list.
nextcrm/admin/enqueue/middleActionLine 33Enqueues contact page assets like Choices, Flatpickr, and nextcrm-contact.
nextcrm/enqueue/admin/dependencyFilterLine 72Adds nextcrm-contact script as an admin dependency.

nextcrm/admin_menu/bottom

Registers the Contact module submenus inside the NextCRM admin menu.

Code Reference

add_action('nextcrm/admin_menu/bottom', [$this, 'register_menus']);

Callback

public function register_menus( $menulist ) {
    // Add Contacts, Add New, Lists, Tags, Contact Settings menus
}

Use Case

This hook is used internally to attach the Contact menu to the NextCRM dashboard.

nextcrm/enqueue/admin/page/dependency

Adds contact-related pages to the list of pages where admin assets should load.

Code Reference

add_filter('nextcrm/enqueue/admin/page/dependency', function( $pages = []){
    $pages[] = 'edit-' . nextcrm_manager()->contact->get_posttype();
    $pages[] = nextcrm_manager()->contact->get_posttype();
    return $pages;
});

Example

add_filter('nextcrm/enqueue/admin/page/dependency', function($pages) {
    $pages[] = 'my-custom-contact-page';
    return $pages;
});

nextcrm/admin/notices/dependency

Controls where NextCRM admin notices should be hidden or handled.

Code Reference

add_filter('nextcrm/admin/notices/dependency', function( $items = []){
    $items[] = nextcrm_manager()->contact->get_posttype();
    return $items;
});

Example

add_filter('nextcrm/admin/notices/dependency', function($items) {
    $items[] = 'ncrm_contact';
    return $items;
});

nextcrm/admin/enqueue/middle

Loads the contact page CSS and JS files.

Code Reference

add_action('nextcrm/admin/enqueue/middle', function(){
    wp_enqueue_style('choices', nextcrm_core()->vendor . 'choices/choices.min.css');
    wp_enqueue_script('choices', nextcrm_core()->vendor . 'choices/choices.min.js');
});

nextcrm/enqueue/admin/dependency

Adds nextcrm-contact as a dependency in the NextCRM admin enqueue system.

Code Reference

add_filter('nextcrm/enqueue/admin/dependency', function( $dep ){
    $dep[] = 'nextcrm-contact';
    return $dep;
});

Example

add_filter('nextcrm/enqueue/admin/dependency', function($dep) {
    $dep[] = 'my-custom-contact-script';
    return $dep;
});

Next

Leave a Reply

Your email address will not be published. Required fields are marked *