• Resolved Mxlaxe

    (@mxlaxe)


    Hi,

    I updated from v3 to v6 (I know) and my [site_reviews …] shortcodes aren’t working anymore.

    I know the parameters have changed. I ended up with this:

    [site_reviews display="1" assigned_posts="post_id"]

    And this does not show anything.

    It is worth mentioning that the review on the very same page were working before and are not deleted.

    Also tried in a blank page the [site_reviews] shortcode by itself, but same, no output, just blank.

    I also used the tools to reset everything possible etc but still no luck.

    The [site_reviews_summary] shortcode however works.

    Any idea what could go wrong ?

    Thank you

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    <!– wp:paragraph –>
    <p>Did you first try running the plugin migration on the Site Reviews Tools page? See also the Upgrade Guide on the Help page.</p>
    <!– /wp:paragraph –>

    Thread Starter Mxlaxe

    (@mxlaxe)

    Yes, I ran the migration, optimized everything I could from the tools section but nothing worked so far. I’m not sure what to do next, but I will try something else.

    Plugin Author Gemini Labs

    (@geminilabs)

    Please use the Contact Support section on the Help & Support page to contact me directly.

    Thread Starter Mxlaxe

    (@mxlaxe)

    Okay I got some updates,

    My website is using several hooks provided by the plugin and it seems that they cause the problem because the shortcode works if I comment it all out but then I lose all my custom modifs.

    In the v3, I added some custom field in the review form and I got to something working with these filters (2 of them were deprecated and I changed the filters to their new name)

    Can you spot something wrong in the below code ? (was working in v3)

    * @return array
    */
    add_filter( 'site-reviews/review-form/order', function( $order ) {
    // The $order array contains the field keys returned below.
    // Simply add any custom field keys that you have added and change them to the desired order.
    return [
    'rating',
    'title',
    'website', // this is a custom field key
    'content',
    'name',
    'email',
    'terms',
    ];
    }); /**
    * Modifies the submission form field rules
    * Paste this in your active theme's functions.php file.
    * @return array
    */
    add_filter( 'site-reviews/validation/rules', function( $rules ) {
    $rules['website'] = 'required';
    return $rules;
    }); /**
    * Displays custom fields in the Review's "Details" metabox
    * Paste this in your active theme's functions.php file.
    * @return array
    */
    add_filter( 'site-reviews/metabox/details', function( $metabox, $review ) {
    foreach( $review->custom as $key => $value ) {
    $metabox[$key] = $value;
    }
    return $metabox;
    }, 10, 2 ); /**
    * Renders the custom review fields
    * Paste this in your active theme's functions.php file.
    * In order to display the rendered custom fields, you will need to use a custom "review.php" template
    * as shown in the plugin FAQ ("How do I change the order of the review fields?")
    * and you will need to add your custom keys to it, for example: {{ name_of_your_custom_key }}
    * @return array
    */
    add_filter('site-reviews/review/build/after', function( $renderedFields, $review ) {
    foreach ($review->custom as $key => $value) {
    if (substr($value, 0, 1) === '@' && filter_var(substr($value, 1), FILTER_VALIDATE_URL)) {
    $rel = "";
    $url = substr($value, 1);
    } else {
    $rel = ' rel="nofollow"';
    $url = $value;
    }
    if ($value) {
    $renderedFields[$key] = '<div class="glsr-custom-' . $key . '"><a target="_blank" href="' . $url . '" title="' . $url . '"' . $rel . '>' . get_host($url) . '</a></div>';
    } else {
    $renderedFields[$key] = '';
    }
    return $renderedFields;
    }
    return;
    }, 10, 2);

    I am also using a custom site-reviews/review.php template like so:

    <?php defined( 'WPINC' ) || die; ?>
    
    <div class="glsr-review">
        {{ title }}
        {{ rating }}
        {{ date }}
        {{ assigned_to }}
        {{ content }}
        {{ avatar }}
        {{ author }}
        {{ website }}
        {{ response }}
    </div>
    Plugin Author Gemini Labs

    (@geminilabs)

    Try changing this:

    return $renderedFields;
    }
    return;
    }, 10, 2);

    To this:

    }
    return $renderedFields;
    }, 10, 2);

    And this:

    <div class="glsr-review">
    

    To this:

    <div class="glsr-review" id="review-{{ review_id }}" data-assigned='{{ assigned }}'>

    Keep in mind that adding custom fields to the form is not supported here, so you may need to also refer to the original snippet: https://pastebin.com/4fvKErcp

    Thread Starter Mxlaxe

    (@mxlaxe)

    Yes !

    It is working now, I also followed your link and made a couple minor changes and it’s fine!

    Thank you so much for your help!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘[site_reviews] shortcode not working after update’ is closed to new replies.