Filter hooks

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

Top ↑

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:

$resultThe 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

Top ↑

This hook can be used to modify the list of available reactions.

Source:

$reactions = apply_filters( 'da_r_get_all_reactions', $reactions );

Params:

$reactionsThe 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

Top ↑

This hook can be used to modify the frontend widget HTML

Source:

$result = apply_filters( 'da_r_get_buttons', $buttons_html, $reactions );

Params:

$buttons_htmlThe widget HTML code
$reactionsThe 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

Top ↑

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:

$resultThe comments recordset
$reaction_idThe reaction ID
$limitThe 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

Top ↑

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_queryThe prepared query string
$reaction_idThe reaction ID
$limitThe 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

Top ↑

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:

$resultThe comments recordset
$item_typeThe content type, such as ‘post’ or ‘comment’
$reaction_idThe reaction ID
$limitThe 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

Top ↑

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_queryThe prepared query string
$item_typeThe content type, such as ‘post’ or ‘comment’
$reaction_idThe reaction ID
$limitThe 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

Top ↑

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_clauseThe clause string
$date_rangeThe date range requested (e.g. “seven-days”)
$column_nameThe 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

Top ↑

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_clauseThe clause string
$filter_typesAn array of strings representing the types of filter
$filter_idsAn 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

Top ↑

This hook can be used to modify the extracted reaction.

Source:

$result = apply_filters( 'da_r_get_reaction_by_id', $result, $reaction_id );

Params:

$resultThe reaction record
$reaction_idThe 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

Top ↑

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:

$reactionThe reaction instance
$item_idThe ID of the content
$item_typeThe 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

Top ↑

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:

$resultThe reactions list
$item_idThe ID of the content
$item_typeThe 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

Top ↑

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:

$reactionThe reaction instance
$item_idThe content ID
$item_typeThe content type, such as ‘post’ or ‘comment’
$skip_cacheBoolean flag to skip internal cache
$user_tokenThe 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

Top ↑

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:

$resultThe query result
$content_typeThe 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

Top ↑

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:

$queryThe prepared query string
$content_typeThe 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 );