Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Adds a link of the assigned page to the Site Reviews summary text
- * Paste this in your active theme's functions.php file.
- * @param array $fields
- * @return array
- */
- add_filter( 'site-reviews/rendered/template/reviews-summary', function( $template, $data ) {
- if( !empty( $data['context']['assigned_to'] )) {
- $permalink = get_the_permalink( $data['context']['assigned_to'] );
- $title = get_the_title( $data['context']['assigned_to'] );
- if( $permalink && $title ) {
- $assignedToPermalink = sprintf( ' of <a href="%s">%s</a>', $permalink, $title );
- $template = preg_replace( '/(\(based on \d+ reviews?)(\))/', '$1'.$assignedToPermalink.'$2', $template );
- }
- }
- return $template;
- }, 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement