Skip to content

Instantly share code, notes, and snippets.

View VictorPietro's full-sized avatar

Victor Pietro Moreno VictorPietro

View GitHub Profile
@VictorPietro
VictorPietro / jet-engine-listing-grid-load-more-retrigger.js
Created April 20, 2025 10:48
Retrigger After Jet Engine "Load More" event handler
// ## Description
// This code listens for the `jet-engine/listing-grid/after-load-more` event triggered by JetEngine's infinite scroll or "load more" feature. When the event is fired (i.e., new content is loaded into the listing grid), it reinitializes custom scripts by calling the `initializeCustomScripts` function.
// ## How to Use
// 1. Ensure you have a function named `initializeCustomScripts` defined in your JavaScript. This function will handle reinitialization of any custom functionality for the newly loaded content.
// 2. Include this script in your project. It will automatically attach a listener to the `jet-engine/listing-grid/after-load-more` event.
// 3. Check the browser console for the log message: `"Infinite scroll content loaded (after-load-more). Reinitializing custom scripts..."` to confirm the event is being detected.
(($) => {
$(document).ready(function () {
@VictorPietro
VictorPietro / jsf_custom_search.php
Created April 19, 2025 22:21
Jet Smart Filters JSF Complex Query (meta field, taxonomy)
/**
* Filter for searching publications by post_title, meta field 'authors', and taxonomy 'conference' in JetSmartFilters.
* Uses the _search_publications query variable.
*/
add_filter( 'jet-smart-filters/query/final-query', function( $query ) {
global $wpdb;
// Loop through meta_query to check for _search_publications
foreach ( $query['meta_query'] as $index => $meta_query_item ) {
if ( isset( $meta_query_item['key'] ) && $meta_query_item['key'] === '_search_publications' ) {
@VictorPietro
VictorPietro / jsf-user-search.php
Created April 19, 2025 10:34
Pesquisar por E-mail do User e outros campos com JetSmartFilters no WordPress
/* Adicione esse trecho no functions.php do tema [ou tema filho mais seguro] */
/* no campo search do smartfilters no query variable coloque:
user_prop::user_email; user_prop::user_login; user_prop::user_nicename; user_prop::ID; user_prop::user_url
--->> importante use ponto e virgula (;) para adicionar mais de um termo caso necessário. */
/*
Veja o Prints:
https://imgur.com/a/amQwmzv
https://imgur.com/a/3foNmbH
*/
@VictorPietro
VictorPietro / ajax-reload-listing-table-jetpopup-after-form-submit.js
Last active March 4, 2025 03:10
AJAX Reload Listing/Table and JetPopup after JetFormBuilder submit
jQuery(document).ready(function($) {
$('.micro-unit-type-submit-button').on('click', function() {
let listingSelector = '.elementor-element-085ed4a'; // Your listing grid selector
// Reload title
$('.elementor-element-bdcf9fb').load(window.location.href + ' .elementor-element-bdcf9fb');
// Reload the listing grid
$(listingSelector).load(window.location.href + ' ' + listingSelector, function() {
console.log('Listing reloaded!');
@VictorPietro
VictorPietro / jet-engine-add-current-website-macro.php
Created February 10, 2025 22:47
Jet Engine - Add Current Website Macro
<?php
/**
* Note!
* Register macros on jet-engine/register-macros action only,
* as the base macro class \Jet_Engine_Base_Macros is not available before that action;
* after it - all macros are registered already
*/
add_action( 'jet-engine/register-macros', function(){
@VictorPietro
VictorPietro / get-jet-engine-glossary-label-by-value.php
Created February 10, 2025 18:54
Get JetEngine's Glossary Label by its Value programatically
<?php
// Get the glossary label by having the value
// Change "35" to the the ID of the glossary
// This ID can be seen when you hit "save" while inspecting admin-ajax.php request on Network Dev Tools tab (item[id])
// Or you can also check it in the database
$glossary_value = 'example';
$glossary_label = jet_engine_label_by_glossary($glossary_value, 35);
@VictorPietro
VictorPietro / search-by-year-jet-smart-filters.php
Created February 7, 2025 02:18
Search by year Jet Smart Filters
<?php
/* Search by year Jet Smart Filters */
/* I want to share this code that allows you to search by year on Jet Smart Filters. */
// 1. Create a meta field named 'example-date', which is type date saved as timestamp.
// 2. Set a query on query builder that will fetch all the years of a meta field (in this case, meta field is named example-date, created on step 1).
@VictorPietro
VictorPietro / jet-fb-form-statuses-hook.php
Created January 24, 2025 13:45
Set JetFormBuilder form statuses. All credits to @girafffee
<?php
use Jet_Form_Builder\Exceptions\Action_Exception;
add_action( 'jet-form-builder/custom-action/test_action', function ( $request, $handler ) {
if ( empty( $request['age'] ) ) {
/**
* You can use one of the default statuses
* 'success' => 'Form successfully submitted.',
* 'failed' => 'There was an error trying to submit form. Please try again later.',
@VictorPietro
VictorPietro / jsf-hide-before-filter.html
Created January 22, 2025 23:01
JetSmartFilters Hide widget before filtering (also optionally hide when no filter is applied anymore). All credits to Crocoblock, just saving this for myself. Add the class to the listing grid that you want to hide.
<style>
body:not(.elementor-editor-active) .hide-listing {
display: none;
height: 0;
}
</style>
<script>
@VictorPietro
VictorPietro / current-object-property-macro.php
Last active January 22, 2025 22:16
JetEngine Get current object property macro. All credits to Crocoblock. Just saving this for me
<?php
/* Add this to functions.php or using a code snippet plugin */
add_action( 'jet-engine/register-macros', function(){
/**
* Return current object property.
*/
class Current_Object_Prop_Macro extends \Jet_Engine_Base_Macros {