Skip to content

Instantly share code, notes, and snippets.

View VictorPietro's full-sized avatar

Victor Pietro Moreno VictorPietro

View GitHub Profile
@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 {
@VictorPietro
VictorPietro / close_jetpopup_after_jetformbuilder_successful_submit.js
Created January 15, 2025 06:27
Close a JetPopup after successful JetFormBuilder submit
jQuery(document).ready(function($) {
// Listen for the JetFormBuilder submit success event
$(document).on('jet-form-builder/ajax/on-success', function() {
// Wait for 2 seconds after the form is successfully submitted
setTimeout(function() {
// Simulate a click on the popup close button
$('.jet-popup__close-button').trigger('click');
}, 2000); // Time in milliseconds (2 seconds)
});
});
@VictorPietro
VictorPietro / update_jetengine_option.php
Created January 7, 2025 20:43
Update JetEngine Option programatically through PHP
<?php
// Change for the Option you want.
// Can be seen on the URL when you enter on the option page: https://yoursite.com/wp-admin/admin.php?page=example-option
$option_name = 'example-option';
// Get the options page values
$options = get_option($option_name);
// Update the option field with the values you want.
$options['example_option_field'] = 'new value';
@VictorPietro
VictorPietro / translate_jetengine_calendar.php
Created January 4, 2025 19:42
Translate JetEngine Calendar to Portuguese (Brazil) or other languages
/* Put this on your functions.php */
add_filter( 'jet-smart-filters/filters/localized-data', 'translate_datepicker_texts', 100 );
function translate_datepicker_texts( $args ) {
if ( isset( $args['datePickerData'] ) ) {
// Substitui os textos em inglês pelas traduções para português brasileiro.
$args['datePickerData']['closeText'] = 'Fechar';
$args['datePickerData']['prevText'] = 'Anterior';
$args['datePickerData']['nextText'] = 'Próximo';
$args['datePickerData']['currentText'] = 'Hoje';
@VictorPietro
VictorPietro / return_glossary_items_jetengine.php
Created December 28, 2024 12:45
PHP Function to return JetEngine's Glossary items
/* This will return the glossary items as a value:label array */
jet_engine()->glossaries->filters->get_glossary_options( $glossary_id );
@VictorPietro
VictorPietro / redirect_to_cct_single_page.php
Last active March 22, 2025 19:15
JetFormBuilder and JetEngine - Redirect to CCT Single Page after CCT was created on JetFormBuilder
/* By Victor Pietro (nectho)
This is the easiest way that I've found to redirect user to a CCT Single Page after the user has created this CCT with a form from JetFormBuilder.
1. First, on the form you have to set a post-submit action to redirect user to a page.
2. Then, set Custom URL, and on Redirect URL, put an existent page (or for an existing CPT). In this example, I'll use /consultation/
3. For URL Query Arguments, add the inserted_cct field (on my example, the CCT is consultation, so I add inserted_cct_consultation)
4. Now on your functions.php (if you have a Child theme installed), or with a code snippet plugin, you just put the function below.
5. You have to adjust the function. On /consultation/, put the page you've put on form post-submit action
6. You also have to change the isset( $_GET['inserted_cct_consultation'] ) part to the inserted_cct of your CCT.