1. Home
  2. Plugins
  3. Internal Comments
  4. Hooks and functions reference

Hooks and functions reference

Internal Comments provides a few helpful functions for interacting with the data and some useful hook for extending its functionality.

Functions

All functions are located in the functions.php and functions-premium.php files. You can check their parameters and return values in said locations. The components IDs can be found in the config_prod.php and config-premium_prod.php files.

Function nameDescription
dws_ic_di_containerReturns the dependency injection container instance.
dws_ic_instanceReturns the plugin’s main class instance from the DI container.
dws_ic_componentReturns a given plugin component from the DI container by its ID.
dws_ic_get_raw_settingReturns the raw database value of a given setting.
dws_ic_get_validated_settingReturns the validated database value of a given setting.
dws_ic_get_selected_post_typesReturns the list of post types that have been selected in the settings for internal comments .
dws_ic_are_enabled_private_commentsReturns whether the private comments feature is currently turned on or off in the settings.
Function nameDescription
dws_ic_is_private_commentReturns whether a given internal comment is marked as private or not.
dws_ic_is_internal_commentReturns whether a given comment is a DWS Internal Comment or not.
dws_ic_get_internal_commentsQueries the database for internal comments for a given post and returns them as DWS_Internal_Comment objects.
dws_ic_get_internal_comments_from_trash_metaA peculiarity of WP’s handling of comments for trashed posts. Use to return internal comments for posts in the trash.

Hooks

All hook tags are computationally generated to ensure uniqueness. It is possible to reverse-engineer the end-result, but it is recommended to just use the same helpers in order to ensure future-compatibility.

There are 2 helper functions to help you generate our hooks:

Function nameDescription
dws_ic_get_hook_tagReturns a plugin-level hook.
dws_ic_get_component_hook_tagReturns a component-level hook.

It’s recommended to use the action dws_ic_initialized to register your hooks. It’s guaranteed that the functions above will be present and work on this action.

Filter comment data for new internal comments

add_action( 'dws_ic_initialized', function() {
    add_filter(
        dws_ic_get_hook_tag( 'create_comment_data' ),
        function( array $comment_data ): array {
            return $comment_data;
        }
    );
} );Code language: PHP (php)
Updated on December 3, 2021

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
CONTACT SUPPORT