A comprehensive guideline on how to use Real Testimonials Pro filter hooks. We have added the following hooks for developers to extend functionalities. Simply add the following custom code to your current theme’s functions.php file. It’s recommended to keep the code in the functions.php file of your child theme. Because you might lose your customizations if the theme is updated. Keeping the modified codes in your parent theme’s child theme is therefore the best practice.
1) How to grant Editors access to the plugin
2) How to remove any Safe Web Fonts from the plugin
3) How to add custom fonts in the plugin
4) How to load the Testimonial style in the header section
5) How to change the “No testimonials found” text
6) How to fix the translation issue with the WPML plugin
7) How to change the “End of content” text
8) How to add custom social profile icons
9) How to add Custom Google Fonts in the Typography
1) How to grant Editors access to the plugin
If you want to give the plugin access to the Editors you can do it easily with the help of the following custom code. If you check the code you can see there is a filter hook (sp_testimonial_post_type_args) available in the plugin which allows you to modify the plugin’s functionality.
// Plugin access to editors function sp_real_testimonial_ui_permission_editor() { return 'edit_others_posts'; } add_filter( 'sp_real_testimonial_ui_permission', 'sp_real_testimonial_ui_permission_editor' );
2) How to remove any Safe Web Fonts from the plugin
Suppose you don’t want to use any specific Safe Web Fonts of the plugin, and you don’t want to display them in the Typography section. Then you can do this easily with the following custom code. If you check the code you will see there is a filter hook available (spftestimonial_field_typography_safewebfonts) in the plugin by which you can easily remove the specific font. You just need to put the array key number of the font in the function.
function typography_safewebfonts_remove($safewebfonts) { unset($safewebfonts['0']); // To remove the Arial font return $safewebfonts; } add_filter( 'spftestimonial_field_typography_safewebfonts', 'typography_safewebfonts_remove' );
3) How to add custom fonts in the plugin
If you want to add any custom font to the plugin. You can do this easily with the custom code below. But your custom font must be enqueued/loaded in your theme or site. Then you just need to write the font name in the function below. If you check the code you will see there is a filter hook available (spftestimonial_field_typography_customwebfonts) in the plugin by which you can easily add custom fonts.
function sp_custom_fonts(){ $custom_fonts = array( 'Jupiter SP', 'Sonar Bangla', 'Ruposhi Bangla' ); return $custom_fonts; } add_filter( 'spftestimonial_field_typography_customwebfonts', 'sp_custom_fonts' );
4) How to load the Testimonial style in the header section
If you want to load the testimonial style in the header section you can easily do this with the following custom code. Just copy and paste the following code into your current theme’s functions.php file.
add_filter( 'sp_testimonial_style_load_in_header', '__return_true' );
5) How to change the “No testimonials found” text
If you don’t like the default “No testimonials found” text when there are no testimonials available or found, you can change the text as you want by replacing the default text with yours. You can do this with the custom code below. If you check the code, you will see there is a filter hook available (sptpro_not_found_any_testimonial) in the plugin by which you can easily do the modification.
function sptpro_not_found_text(){ return __( 'Sorry, no testimonials found', 'testimonial-pro' ); } add_filter( 'sptpro_not_found_any_testimonial', 'sptpro_not_found_text' );
6) How to fix the translation issue with the WPML plugin
When the plugin is translated with the WPML plugin into a specific language, sometimes it doesn’t display properly on the front end. With the custom code below, you can fix the issue easily.
add_filter( 'spt_testimonial_pro_suppress_filters', '__return_false' );
7) How to change the “End of content” text
If you don’t like the default “End of content” text when there are no testimonials available, you can change the text as you want by replacing the default text with yours. You can do this with the custom code below. If you check the code, you will see there is a filter hook available (sp_testimonial_pro_pagination_end_content_text) in the plugin by which you can easily do the modification.
function sp_testimonial_pro_pagination_end_content_text_modified(){ return __( 'No more testimonials', 'testimonial-pro' ); } add_filter( 'sp_testimonial_pro_pagination_end_content_text', 'sp_testimonial_pro_pagination_end_content_text_modified' );
8) How to add custom social profile icons
If you want to add custom icons to your social profiles, you can do this easily with the custom code below. You just need to write the icon name and class from the Font Awesome icon list into the array of the following function. If you check the code, you will see there is a filter hook available (sp_testimonial_social_profile_list) in the plugin by which you can easily make the modification. For example, I have added two icons to the code.
function sp_testimonial_social_profile_list_custom(){ $custom_icon_list = array( 'email' => array( 'name' => esc_html__('Email', 'testimonial-pro'), 'icon' => '<i class="fa fa-envelope"></i>', ), 'download' => array( 'name' => esc_html__('Download', 'testimonial-pro'), 'icon' => '<i class="fa fa-download"></i>', ) ); return $custom_icon_list; } add_filter('sp_testimonial_social_profile_list', 'sp_testimonial_social_profile_list_custom');
9) How to add Custom Google Fonts in the Typography
If you want to add any custom font to the plugin. You can do this easily with the custom code below. But your custom font must be enqueued/loaded in your theme or site. Then you just need to write the font name in the function below. If you check the code you will see there is a filter hook available (spftestimonial_field_typography_googlewebfonts) in the plugin by which you can easily add custom fonts.
function sp_custom_google_fonts() { $webfonts = array( 'Jupiter SP', 'Sonar Bangla', 'Ruposhi Bangla' ); return $webfonts; } add_filter( 'spftestimonial_field_typography_googlewebfonts', 'sp_custom_google_fonts' );