Action hooks are used to modify data in runtime while executing other tasks.
DaReactions adds several filter hooks since version 4.0.0
- da_r_get_all_content_reactions
- da_r_get_all_reactions
- da_r_get_buttons
- da_r_get_comments_by_reaction
- da_rget_comments_by_reaction_query
- da_r_get_contents_by_reaction
- da_r_get_contents_by_reaction_query
- da_r_get_date_clause
- da_r_get_filter_clause
- da_r_get_reaction_by_id
- da_r_get_main_reaction_for_content
- da_r_get_reactions_for_content
- da_r_get_reaction_for_user
- da_r_get_total_reactions_for_content_type
- da_r_get_total_reactions_for_content_type_query
da_r_get_all_content_reactions
This hook can be used to modify the complete list of reactions, as used in the dashboard total reactions widget.
Source:
apply_filters( 'da_r_get_all_content_reactions', $result );
Params:
$result | The reactions recordset |
Usage:
function modify_reactions( $reactions_list ) {
/// ... do something.
return $reactions_list;
}
add_filter( 'da_r_get_all_content_reactions', 'modify_reactions' );
da_r_get_all_reactions
This hook can be used to modify the list of available reactions.
Source:
$reactions = apply_filters( 'da_r_get_all_reactions', $reactions );
Params:
$reactions | The reactions recordset |
Usage:
function modify_reactions( $reactions_list ) {
/// ... do something.
return $reactions_list;
}
add_filter( 'da_r_get_all_reactions', 'modify_reactions' );
da_r_get_buttons
This hook can be used to modify the frontend widget HTML
Source:
$result = apply_filters( 'da_r_get_buttons', $buttons_html, $reactions );
Params:
$buttons_html | The widget HTML code |
$reactions | The reactions to display |
Usage:
function modify_buttons( $buttons_html, $reactions ) {
/// ... do something.
return $buttons_html;
}
add_filter( 'da_r_get_buttons', 'modify_buttons', 10, 2 );
da_r_get_comments_by_reaction
This hook can be used to modify the list of available reactions used by the widget Content with most reactions.
Source:
$result = apply_filters( 'da_r_get_comments_by_reaction', $result, $reaction_id, $limit );
Params:
$result | The comments recordset |
$reaction_id | The reaction ID |
$limit | The maximum number of results requested |
Usage:
function modify_comments( $comments, $reaction_id, $limit ) {
/// ... do something.
return $comments;
}
add_filter( 'da_r_get_comments_by_reaction', 'modify_comments', 10, 3 );
da_r_get_comments_by_reaction_query
This hook can be used to modify the query used by the widget Content with most reactions to extract comments list by reaction.
Source:
$result = apply_filters( 'da_r_get_comments_by_reaction_query', $prepared_query, $reaction_id, $limit );
Params:
$prepared_query | The prepared query string |
$reaction_id | The reaction ID |
$limit | The maximum number of results requested |
Usage:
function modify_comments_query( $prepared_query, $reaction_id, $limit ) {
/// ... do something.
return $prepared_query;
}
add_filter( 'da_r_get_comments_by_reaction_query', 'modify_comments_query', 10, 3 );
da_r_get_contents_by_reaction
This hook can be used to modify the list of available reactions used by the Content by reactions widget.
Source:
$result = apply_filters( 'da_r_get_contents_by_reaction', $result, $item_type, $reaction_id, $limit );
Params:
$result | The comments recordset |
$item_type | The content type, such as ‘post’ or ‘comment’ |
$reaction_id | The reaction ID |
$limit | The maximum number of results requested |
Usage:
function modify_contents( $contents, $item_type, $reaction_id, $limit ) {
/// ... do something.
return $contents;
}
add_filter( 'da_r_get_contents_by_reaction', 'modify_contents', 10, 4 );
da_r_get_contents_by_reaction_query
This hook can be used to modify the query used by the Content by reactions widget to extract contents list by reaction.
Source:
$result = apply_filters( 'da_r_get_contents_by_reaction_query', $prepared_query, $item_type, $reaction_id, $limit );
Params:
$prepared_query | The prepared query string |
$item_type | The content type, such as ‘post’ or ‘comment’ |
$reaction_id | The reaction ID |
$limit | The maximum number of results requested |
Usage:
function modify_contents_query( $prepared_query, $item_type, $reaction_id, $limit ) {
/// ... do something.
return $prepared_query;
}
add_filter( 'da_r_get_contents_by_reaction_query', 'modify_contents_query', 10, 4 );
da_r_get_date_clause
This hook can be used to modify the date clause for the queries that extract the records for the Votes list Page.
Source:
$date_clause = apply_filters( 'da_r_get_date_clause', $date_clause, $date_range, $column_name );
Params:
$date_clause | The clause string |
$date_range | The date range requested (e.g. “seven-days”) |
$column_name | The date field name in database (i.e. “created_at”) |
Usage:
function modify_date_clause( $date_clause, $date_range, $column_name ) {
/// ... do something.
return $date_clause;
}
add_filter( 'da_r_get_date_clause', 'modify_date_clause', 10, 3 );
da_r_get_filter_clause
This hook can be used to modify the filter clause for the queries that extract the records for the Votes list Page.
Source:
$filter_clause = apply_filters( 'da_r_get_filter_clause', $filter_clause, $filter_types, $filter_ids );
Params:
$filter_clause | The clause string |
$filter_types | An array of strings representing the types of filter |
$filter_ids | An array of strings representing the values of filter |
Usage:
function modify_clause( $filter_clause, $filter_types, $filter_ids ) {
/// ... do something.
return $filter_clause;
}
add_filter( 'da_r_get_filter_clause', 'modify_clause', 10, 3 );
da_r_get_reaction_by_id
This hook can be used to modify the extracted reaction.
Source:
$result = apply_filters( 'da_r_get_reaction_by_id', $result, $reaction_id );
Params:
$result | The reaction record |
$reaction_id | The reaction ID |
Usage:
function modify_reaction( $result, $reaction_id ) {
/// ... do something.
return $result;
}
add_filter( 'da_r_get_reaction_by_id', 'modify_reaction', 10, 2 );
da_r_get_main_reaction_for_content
This hook can be used to modify the reaction extracted as main reaction for a specific content.
Source:
$result = apply_filters( 'da_r_get_main_reaction_for_content', $result, $item_id, $item_type );
Params:
$reaction | The reaction instance |
$item_id | The ID of the content |
$item_type | The content type, such as ‘post’ or ‘comment’ |
Usage:
function modify_reaction( $reaction, $item_id, $item_type ) {
/// ... do something.
return $reaction;
}
add_filter( 'da_r_get_main_reaction_for_content', 'modify_reaction', 10, 3 );
da_r_get_reactions_for_content
This hook can be used to modify the reactions extracted for a specific content.
Source:
$result = apply_filters( 'da_r_get_reactions_for_content', $result, $item_id, $item_type );
Params:
$result | The reactions list |
$item_id | The ID of the content |
$item_type | The content type, such as ‘post’ or ‘comment’ |
Usage:
function modify_reactions( $result, $item_id, $item_type ) {
/// ... do something.
return $result;
}
add_filter( 'da_r_get_reactions_for_content', 'modify_reactions', 10, 3 );
da_r_get_reaction_for_user
This hook can be used to modify the reaction extracted for user.
Source:
$result = apply_filters( 'da_r_get_reaction_for_user', $result, $item_id, $item_type, $skip_cache, $user_token );
Params:
$reaction | The reaction instance |
$item_id | The content ID |
$item_type | The content type, such as ‘post’ or ‘comment’ |
$skip_cache | Boolean flag to skip internal cache |
$user_token | The user unique identifier |
Usage:
function modify_reactions( $reaction, $item_id, $item_type, $skip_cache, $user_token ) {
/// ... do something.
return $reaction;
}
add_filter( 'da_r_get_reaction_for_user', 'modify_reactions', 10, 5 );
da_r_get_total_reactions_for_content_type
This hook can be used to modify the number of total reactions grouped by content type.
Source:
$query = apply_filters( 'da_r_get_total_reactions_for_content_type_query', $result, $content_type );
Params:
$result | The query result |
$content_type | The content type, such as ‘post’ or ‘comment’ |
Usage:
function modify_total( $result, $content_type ) {
/// ... do something.
return $result;
}
add_filter( 'da_r_get_total_reactions_for_content_type_query', 'modify_total', 10, 2 );
da_r_get_total_reactions_for_content_type_query
This hook can be used to modify the query used to extract the total number of reactions grouped by content type.
Source:
$query = apply_filters( 'da_r_get_total_reactions_for_content_type_query', $query, $content_type );
Params:
$query | The prepared query string |
$content_type | The content type, such as ‘post’ or ‘comment’ |
Usage:
function modify_total_query( $prepared_query, $item_type ) {
/// ... do something.
return $prepared_query;
}
add_filter( 'da_r_get_total_reactions_for_content_type_query', 'modify_total_query', 10, 2 );