Skip to content

Instantly share code, notes, and snippets.

View Crocoblock's full-sized avatar

Crocoblock Crocoblock

View GitHub Profile
@Crocoblock
Crocoblock / code.php
Last active April 14, 2025 07:57
JetBooking / Exclude posts that are unavailable on check-in and check-out dates
<?php
add_filter( 'jet-smart-filters/query/final-query', function( $query ) {
if ( empty( $query['meta_query'] ) ) {
return $query;
}
$store_type = jet_abaf()->settings->get( 'filters_store_type' );
foreach ( $query['meta_query'] as $index => $meta_query ) {
@Crocoblock
Crocoblock / code.php
Created April 10, 2025 08:28
JetBooking - Price Filter Based on Selected Date Range
<?php
add_filter( 'jet-smart-filters/query/final-query', function( $query ) {
if ( empty( $query['meta_query'] ) ) {
return $query;
}
foreach ( $query['meta_query'] as $index => $meta_query ) {
if ( isset( $meta_query['key'] ) && '_seasonal_price' === $meta_query['key'] ) { // `_seasonal_price` unique key from Query Variable filter option.
$excluded = jet_abaf_get_excluded_apartments( $meta_query['value'] );
@Crocoblock
Crocoblock / wysiwyg_config.php
Created February 20, 2025 14:35
JetFormBuilder / How to customize Wysiwyg Field in JetFormBuilder & JetEngine Forms
<?php
$wysiwygConfig = function ( $wysiwyg_config ) {
/**
* You can find a list of all available plugins as folder names
* in wp-includes/js/tinymce/plugins
*/
$plugins = array(
'colorpicker',
'textcolor',
@Crocoblock
Crocoblock / code.php
Created January 22, 2025 12:44
JetEngine - Query Results with empty items
<?php
add_action( 'jet-engine/register-macros', function() {
/**
* Return purchased products.
*/
class Query_Results_Macro_With_Empty_Items extends \Jet_Engine\Query_Builder\Macros\Query_Results_Macro {
public function macros_tag() {
return 'query_results_with_empty_items';
@Crocoblock
Crocoblock / code.html
Last active January 21, 2025 18:07
JetPopup Scroll JetEngine Listing Grid slider to a corresponding slide on opening popup
<script>
jQuery( document ).ready( function( $ ){
$( window ).on( 'jet-popup-open-trigger', function( event ) {
let id = event?.popupData?.postId;
if ( ! id ) {
return;
}
@Crocoblock
Crocoblock / code.php
Created December 23, 2024 16:11
JetEngine SEOPress output checkbox/radio/select field, repeater field
<?php
add_filter('seopress_titles_template_variables_array', 'sp_titles_template_variables_array');
add_filter('seopress_titles_template_replace_array', 'sp_titles_template_replace_array');
add_filter('seopress_get_dynamic_variables', 'sp_get_dynamic_variables');
function sp_titles_template_variables_array($array) {
$array[] = '%%je_repeater_template%%';
$array[] = '%%je_checkbox_template%%';
return $array;
@Crocoblock
Crocoblock / code.php
Last active January 13, 2025 15:24
JetEngine Change wrapper tags to <ul> <li> in Listing Grid
<?php
class JEC_Change_Tags {
public function __construct() {
add_filter( 'jet-engine/listing/render/jet-listing-grid/settings', array( $this, 'apply_settings' ) );
add_filter( 'jet-engine/listing/grid/nav-widget-settings', array( $this, 'nav_settings' ), 10, 2 );
add_filter( 'jet-engine/listing/render/default-settings', array( $this, 'default_settings' ) );
}
@Crocoblock
Crocoblock / code.php
Created November 19, 2024 14:57
JetPopup Filter Exclude relation type
<?php
add_filter( 'jet-popup/popup-condition/is_excluded/and', function( $is_excluded, $excludes_matchs, $popup_id ) {
if ( ! get_post( $popup_id ) || false === strpos( get_post( $popup_id )->post_title, '--exclude-or' ) ) {
return $is_excluded;
}
return in_array( true, $excludes_matchs );
@Crocoblock
Crocoblock / code.php
Created October 3, 2024 11:16
JetFormBuilder Change capability user needs to create/edit forms
<?php
add_filter( 'jet-form-builder/capability/form', function( $cap ) {
return 'edit_others_posts';
} );
@Crocoblock
Crocoblock / code.php
Created October 2, 2024 16:29
JetEngine Profile Builder Register Profile Builder macro
<?php
add_filter( 'jet-engine/profile-builder/user-page-title/macros', function( $macros ) {
$macros['do_shortcode'] = array(
'label' => 'Do Shortcode',
'cb' => function() {
return do_shortcode( '[jet_engine_data dynamic_field_source="query_var" dynamic_field_var_name="test1"]' );
},
'allowed_tabs' => array( 'account_page', 'user_page' ),
);