Hooks
Apply Filter Hook
From v4.0.9 Reactive pro provided hooks(apply filter) support. In this docs we will discuss about the hooks we have provided and which one can be useful for you,
All the hooks are available in the below file
reactivepro -> app -> Graph.php &reactivepro -> shortcodes -> preview.php
In the above file you will see that we have added apply_filters
in many places.
reactivepro_get_grid_all_data
The most important hook here is the reactivepro_get_grid_all_data
with this hook you can modify any data needed to show your grid search result.
reactivepro_get_all_users
With this hook you can modify the user data if you are using user search.
reactivepro_get_user_grid_data
Can also be used to modify user data in the user search result.
For now we think only this one is useful for the user. If you want to know more about any hook feel free to reach out to support here https://redqsupport.ticksy.com/
Hooks -> FAQ
How to use hook to show WooCommerce price in the grid?
// The filter callback function.function example_callback($data){foreach ($data['allPosts'] as $key => $value) {$product = wc_get_product($value['ID']);$data['allPosts'][$key]['product_price_html'] = $product->get_price_html();}return $data;}add_filter('reactivepro_get_grid_all_data', 'example_callback', 10);
Now in the grid template code just use
{{{post.product_price_html}}}
How to use Reactive pro hooks?
NB: Check the hooks.md file inside the plugin files to know about hooks and where they are available.
For example if you want to modify the image size, you can try it like below
function reactiveProCustomGridData($data){foreach ($data['allPosts'] as $key => $value) {$data['allPosts'][$key]['300image'] = "your_300_image_url";}return $data;}add_filter('reactivepro_get_grid_all_data', // hook class'reactiveProCustomGridData', // wordpress function10,2);
Now in the grid template code you can use it like below inside the post loop
{{post.300image}}
I want to use a hook for changing the order of categories in my search block. do not want to order by name, but custom array order that I specify in a hook. which hook should I use?
=> ok I solved it, partially. If I order by slug, then I can rename the slugs with "01-***", 02-*" and it won't affect the name of the filters on the frontend, but it will change the order.**
function reactivecatorder ($data){$data = wp_list_sort($data, "slug");return $data;}add_filter('reactivepro_get_all_terms', // hook class'reactivecatorder', // wordpress function10,2);
and another method, by custom order
function reactivecatorder ($data){// put custom order of term ids below$order = array(37, 38, 39, 40, 47, 90, 71, 72, 73, 74, 75, 76, 77, 78, 87, 88, 89);$array = $data;usort($array, function ($a, $b) use ($order) {$pos_a = array_search($a['term_id'], $order);$pos_b = array_search($b['term_id'], $order);return $pos_a - $pos_b;});$data = $array;return $data;}add_filter('reactivepro_get_all_terms', // hook class'reactivecatorder', // wordpress function10,2);