helpful_default_values

Filters the shortcode attributes and allows overriding them. The filter is applied directly when setting the attributes, so you could also use it to translate the individual options for the frontend.

In this example we will show how to make the heading of Helpful able to be translated afterwards:

/**
 * @param array $values
 * @return array
 */
add_filter('helpful_default_values', function (array $values) {
    $values['heading'] = __($values['heading'], 'custom-textdomain');
    return $values;
});

These are the available values:

$values = [
    'heading_tag' => 'h3',
    'heading' => self::convert_tags(get_option('helpful_heading'), $post_id),
    'content' => self::convert_tags(get_option('helpful_content'), $post_id),
    'button_pro' => get_option('helpful_pro'),
    'button_contra' => get_option('helpful_contra'),
    'counter' => (!get_option('helpful_count_hide')),
    'count_pro' => Stats::get_pro($post_id),
    'count_pro_percent' => Stats::get_pro($post_id, true),
    'count_contra' => Stats::get_contra($post_id),
    'count_contra_percent' => Stats::get_contra($post_id, true),
    'credits' => get_option('helpful_credits'),
    'credits_html' => $credits['html'],
    'exists' => User::check_user($user_id, $post_id) ? 1 : 0,
    'exists_text' => self::convert_tags(get_option('helpful_exists'), $post_id),
    'post_id' => $post_id,
];

Was this post helpful?

Top