Skip to content

Instantly share code, notes, and snippets.

View jreviews's full-sized avatar

JReviews jreviews

View GitHub Profile
jreviews /
Created November 24, 2023 12:16
mod_security issues

The following was shared by a client having problems with uploads in JReviews not working:

Never disable all rules !! This could cause serious security issues!

The easiest way to disable individual mod_security rules if you are using cPanel is to install ConfigServer ModSecurity Control and use it to disable individual mod_security rules by ID or via a specific directory.

Otherwise you will need to review and edit specific Apache server files as follows: (Windows Web Server not addressed here)

The mod_security ID's I whitelisted for JReviews Joomla are:

jreviews /
Last active September 21, 2023 21:37
Disable 4SEO in JReviews Listings

JReviews has always had a strong focus in SEO and comes with functionality to add markup, Open Graph and Twitter tags. It also allows using internal features like media and custom fields as part of this functionality which is something 3rd party solutions cannot do unless support is added specifically for them.

If you are using 4SEO for your site, it will add all these SEO features for core functionality and some 3rd party solutions. However, this creates a problem with duplication in JReviews listings. JReviews has it's own data and in some cases may do things differently. So in this case, the recommended solution is to disable the 4SEO tags in JReviews listings to avoid duplication.

This can be done programatically using 4SEO hooks

If you are not using hooks yet, you'll need to create the file at:

  • /libraries/weeblr/forseo_functions.php (when using Joomla)
jreviews /
Last active July 25, 2023 11:42
Vivaz template - open dropdowns on hover
window.addEventListener('DOMContentLoaded', (event) => {

  // Iterate through each main link in the topbar navigation. 
  document.querySelectorAll('.mod-menu > li > a').forEach((mainLink) => {
    const mainLi = mainLink.closest('li'); // Find the closest parent 'li'.
    const mainDropdownElement = mainLi.querySelector('.dropdown-menu'); // Select the dropdown menu of the main link.

    // Execute if both the main link and associated dropdown menu exist.
jreviews /
Last active March 13, 2023 22:25
Joomla Zip::extractNative replacement

The following method is a replacement for Joomla's unzip method to overcome a server's ulimit setting that prevents large packages from unzipping.

The original method can be found in following path. You can open the file and replace the extractNative function with the one below.

  • libraries/vendor/joomla/archive/src/Zip.php

The new function overcomes the server restrictions on the number of simultaneous open files because it doesn't try to extract based on the number of files in the zip archive that could cause issues with ulimit; instead, it extracts everything to a temporary folder using the extractTo method, which reduces the number of simultaneous open files.

Once extraction is completed, it loops over each file in the zip archive and moves files one by one from the temporary directory to the final destination. This approach has good performance because it solves the issue by reducing the maximum number of open files simultaneously, irrespective of the number of files in the zip archive.

jreviews /
Last active December 14, 2022 15:13
Generate GA4 custom report for specific path, event and timeframe using Google Analytics Data API

This code example uses Laravel's Http client.

You need to generate the private key from your service account in a Google Cloud Platform project. Then grant access to your GA4 property to the service account client email.

There are some instructions for doing that in the JReviews Dashboard Addon documentation, which is where the code below comes from.

function getAuthToken($clientEmail, $privateKey)
      $base64URLEncode = function($data) {
jreviews /
Last active September 14, 2022 18:20
PeepSo: Allow searching member profiles with multi-select fields

Within PeepSo fields it's only possible to enable single select lists as searchable. The following code uses PeepSo filters to allow you to include multi-select fields in the members search area by converting them to single select and including the selected value in the database query.

Create a peepso-search-member-profiles.php file in /wp-content/mu-plugins with the following code:


 * Find the field IDs under PeepSo Manage Fields
 * Add the field IDs of multiple select fields you want to show for member search
jreviews /
Last active April 1, 2024 22:22
htmx loading states extension

htmx loading states extension

The loading-states extension allows you to easily manage loading states while a request is in flight, including disabling elements, and adding and removing CSS classes.

Using the extension

Add the hx-ext="loading-states" attribute to the body tag or to any parent element containing your htmx attributes.

Add the following class to your stylesheet to make sure elements are hidden by default:

jreviews /
Created October 28, 2021 20:45
Using match=words attribute in listings shortcode

All searches in JReviews use LIKE to retrieve results. To use an exact word match, it would be necessary to use REGEXP because there aren't any fulltext indexes.

The following filter allows adding the match=word attribute to the listings shortcode to perform a word match. Example usage:

[jreviews type="listings" custom_params="keywords=you" match="word" limit="3"]

The above will match "you", but not "yourself", "yours", etc.

jreviews /
Last active October 26, 2021 14:19
Using a custom parameter to filter results for active events

The filter hook below allows using a custom defined parameter events=active to automatically filter results shown in shortcodes and listings module to only show events that are currently active/open.

Add the code below to filter_functions.php in overrides, and then in your shortcode or listings module add events=open in the custom parameters attribute or setting respectively.

Clickfwd\Hook\Filter::add('pre_get_listings_listings_module_query', function($listingsRepository, $params) 
	$customParams = $params['params']['module']['custom_params'] ?? '';
	if (empty($customParams)) {
jreviews /
Last active October 22, 2021 21:38
PeepSo About Author Snippet in JReviews

The PeepSo About Author output is not present in the JReviews listing detail pages by default. If you want to add it back you can use the following code snippet in the listing detail page or even in the php output format of a banner custom field.

echo PeepSoTemplate::exec_template('blogposts','author_box', 
	['author' => PeepSoUser::get_instance($listing['User']['user_id'])],

You can also add the code after the listing description without template customizations using a JReviews action hook: