Render reviews from PHP without shortcode
-
Hi there,
First of all, I must say I really like this plugin. It has saved me a ton of time.
I only was wondering: if I want to customize a lot of things, the shortcode is not exactly short any more. So for a recent project, I solved that like this:
$reviews_args = [ 'summary="no"', 'review_item_order="author switch text first"', 'date="off"', 'excerpt=""', 'reviews_link="reviews via Google"' ]; $reviews = do_shortcode('[reviews_rating ' . implode(' ', $reviews_args) . ']');
Not the most elegant solution, but it gets the job done.
What I was looking for, is a function/action I can just pass my
$reviews_args
to, without needing to render the shortcode. I searched the plugin code, but I could not find any other way to render the reviews than throughdo_shortcode()
. Or am I missing something?If such a function/action does not exist: it could be as simple as adding an action (as well as a shortcode). One line of code in the plugin would do:
add_action('reviews_rating', array($this, 'wp_display'));
in the plugin’s
google_business_reviews_rating
class.That would enable me to do:
$reviews_args = [ 'summary' => 'no', 'review_item_order' => 'author switch text first', 'date' => 'off', 'excerpt' => '', 'reviews_link' => 'reviews via Google' ]; do_action('reviews_rating', $reviews_args);
instead of using
do_shortcode()
.Just meant as a suggestion, curious what you think ??
- The topic ‘Render reviews from PHP without shortcode’ is closed to new replies.