Skip to content

Instantly share code, notes, and snippets.

Avatar

Alejandro Schmeichler jreviews

View GitHub Profile
@jreviews
jreviews / peepso-about-author.md
Last active Oct 22, 2021
PeepSo About Author Snippet in JReviews
View peepso-about-author.md

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'])],
	true
);

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

@jreviews
jreviews / filter_functions.md
Created Oct 20, 2021
Restrict page access to admins and listing owners
View filter_functions.md

The code below should be placed in the filter_functions.php file in overrides per the JReviews Hooks documentation.

This is meant to be a starting point, not a full-proof solution as JReviews itself doesn't have functionality to limit visibility of user generated content.

// Listing list pages
// https://www.jreviews.com/docs/hooks/pre_get_listings_listpage_query
// https://www.jreviews.com/docs/hooks/pre_get_listings_listings_module_query

function limit_listing_list_visibility_to_owners_and_admins($ListingsRepository, $params)
@jreviews
jreviews / filter_functions.php
Created Jul 19, 2021
Add complete media info to widget & module queries
View filter_functions.php
<?php
Clickfwd\Hook\Filter::add('post_get_listings_listings_module_query', function($listings, $params) {
$config = S2Object::make('config');
$Media = new MediaModel;
$listings = $Media->addMedia(
$listings,
'Listing',
'listing_id',
@jreviews
jreviews / filter_functions.php
Created Jul 10, 2021
Replace Featured label text with custom text
View filter_functions.php
<?php
defined('_JEXEC') or die;
Clickfwd\Hook\Filter::add('listing_status_labels', 'jreviews_change_featured_label_to_urgent');
function jreviews_change_featured_label_to_urgent($labels, $params)
{
if (! isset($labels['featured'])) {
return $labels;
@jreviews
jreviews / filter_functions.php
Created Jul 10, 2021
Add listing labels with custom CSS classes for multiple custom fields
View filter_functions.php
<?php
defined('_JEXEC') or die;
Clickfwd\Hook\Filter::add('listing_status_labels', 'jreviews_custom_labels');
function jreviews_custom_labels($labels, $params)
{
$listing = array_get($params,'listing');
@jreviews
jreviews / hello_elementor.php
Created Jul 8, 2021
Hello Elementor Theme Support for JReviews
View hello_elementor.php
<?php
namespace JReviews\ThemeSupport;
defined( 'ABSPATH' ) || exit;
class HelloElementor
{
public static function init()
{
add_action( 'jreviews_template:before_content', [ __CLASS__, 'output_content_wrapper_open' ] );
@jreviews
jreviews / filter_functions.php
Last active Jun 10, 2021
Apply WordPress shortcodes to JReviews listing detail page text (summary and description) output
View filter_functions.php
<?php
Clickfwd\Hook\Filter::add('post_get_listing_detailpage_query', function($listing, $params)
{
$listing['Listing']['text'] = do_shortcode($listing['Listing']['text']);
return $listing;
});
@jreviews
jreviews / filter_functions.md
Last active Jun 13, 2021
Custom filters for open graph images and meta description in listing detail pages
View filter_functions.md

Customize the open graph image in listing detail pages for individual categories

Clickfwd\Hook\Filter::add('open_graph_tags_before_parse', function($tags, $listing) 
{
	/**
	 * If you specify a category in this array, it will take precedence
	 */
	$imageToCategoriesArray = [
		"images/someimage_opengraph_big.jpg" => [1, 2, 3, 90],
@jreviews
jreviews / filter_functions.php
Created Apr 19, 2021
JReviews filter to hide `write review` in action buttons area for listing owners
View filter_functions.php
<?php
Clickfwd\Hook\Filter::add('listing_list_action_buttons', 'jreviews_hide_write_review_for_owners');
Clickfwd\Hook\Filter::add('listing_detail_action_buttons', 'jreviews_hide_write_review_for_owners');
function jreviews_hide_write_review_for_owners($buttons, $params)
{
if (S2Object::make('auth')->id == $params['listing']['User']['user_id']) {
unset($buttons['write_review']);
}
@jreviews
jreviews / modal-behavior._hs
Last active Apr 8, 2021
Hyperscript modal behavior
View modal-behavior._hs
behavior Modal
init
set my focusRing to (<a, button, input:not([type=hidden]), textarea, select, details/> in me) as Array
end
on open
remove .hide
add { overflow: 'hidden' } to the <body/>
transition <[data-backdrop], [data-content]/> in me opacity from 0 to 1 over 0.3s
focus() the first <input/> in me