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 name | Description |
---|---|
dws_ic_di_container | Returns the dependency injection container instance. |
dws_ic_instance | Returns the plugin’s main class instance from the DI container. |
dws_ic_component | Returns a given plugin component from the DI container by its ID. |
dws_ic_get_raw_setting | Returns the raw database value of a given setting. |
dws_ic_get_validated_setting | Returns the validated database value of a given setting. |
dws_ic_get_selected_post_types | Returns the list of post types that have been selected in the settings for internal comments . |
dws_ic_are_enabled_private_comments | Returns whether the private comments feature is currently turned on or off in the settings. |
Function name | Description |
---|---|
dws_ic_is_private_comment | Returns whether a given internal comment is marked as private or not. |
dws_ic_is_internal_comment | Returns whether a given comment is a DWS Internal Comment or not. |
dws_ic_get_internal_comments | Queries the database for internal comments for a given post and returns them as DWS_Internal_Comment objects. |
dws_ic_get_internal_comments_from_trash_meta | A 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 name | Description |
---|---|
dws_ic_get_hook_tag | Returns a plugin-level hook. |
dws_ic_get_component_hook_tag | Returns a component-level hook. |
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)