Skip to content

Instantly share code, notes, and snippets.

@ihslimn
ihslimn / code.php
Created December 26, 2023 13:43
JetEngine JetSmartFilters CCT REST API Filter by created date
<?php
add_action( 'jet-engine/query-builder/query/after-query-setup', function( $query ) {
if ( $query->query_type !== 'rest-api' || ! is_array( $query->final_query['args'] ?? false ) ) {
return;
}
foreach ( $query->final_query['args'] as $i => $arg ) {
if ( empty( $arg['value'] ) || ! is_scalar( $arg['value'] ) || false === strpos( $arg['value'], 'macros_string::' ) ) {
@ihslimn
ihslimn / code.php
Last active December 21, 2023 13:22
JetFormBuilder Update Field addon - custom callback
<?php
function jfb_tour_get_data( $field_name, $form_id, $form_fields ) {
$args = array(
'tour_id' => $form_fields['tour_id'] ?? '',
'number_of_guests' => $form_fields['number_of_guests'] ?? '',
'date' => $form_fields['date'] ?? '',
);
@ihslimn
ihslimn / code.php
Last active December 19, 2023 12:02
JetEngine SQL Query Prepare string for IN
<?php
add_action( 'jet-engine/query-builder/query/after-query-setup', function( $query ) {
if ( empty( $query->final_query['manual_query'] ) ) {
return;
}
$query->final_query['manual_query'] = preg_replace_callback(
'/\{explode(.+?)explode\}/',
@ihslimn
ihslimn / code.php
Created December 8, 2023 13:17
get range min/max from query
<?php
add_action( 'plugins_loaded', function() {
add_filter('jet-smart-filters/filter-instance/args', function($args) {
$filter_id = $args['filter_id'];
$query_var = get_post_meta($filter_id, '_query_var', true);
$step = get_post_meta($filter_id, '_source_step', true);
$source_cb = get_post_meta($filter_id, '_source_callback', true);
@ihslimn
ihslimn / code.php
Last active December 7, 2023 13:17
JetBooking Set calendar language to site locale
<?php
add_action( 'wp_head', function () { ?>
<script>
jQuery( document ).on( 'jet-booking/init', () => {
window.JetPlugins.hooks.addFilter( "jet-booking.input.config", "jetBooking", modifyBookingConfig );
window.JetPlugins.hooks.addFilter( "jet-booking.calendar.config", "jetBooking", modifyBookingConfig );
@ihslimn
ihslimn / code.php
Created December 4, 2023 19:53
JetBooking Restore booking product if it is not restoring automatically
<?php
add_action( 'init', function() {
if ( ! function_exists( 'jet_abaf' ) || jet_abaf()->settings->get( 'booking_mode' ) !== 'plain' ) {
return;
}
$settings = jet_abaf()->settings;
@ihslimn
ihslimn / code.php
Last active February 15, 2024 16:03
JetEngine Cross-sells & Upsells macros
<?php
add_action( 'jet-engine/register-macros', function(){
if ( ! function_exists( 'WC' ) ) {
return;
}
class WC_Crosssells extends \Jet_Engine_Base_Macros {
@ihslimn
ihslimn / code.php
Created November 20, 2023 12:53
JetSmartFilters Add option like '1000+' to check range
<?php
add_filter( 'jet-smart-filters/filters/filter-options', function( $options, $filter_id ){
$filter_list = array(
'269396' => true
);
if ( ! isset( $filter_list[ $filter_id ] ) ) {
return $options;
@ihslimn
ihslimn / code.php
Created November 20, 2023 12:04
JetEngine Explode String callback
<?php
add_action( 'jet-engine/callbacks/register', function( $callbacks ) {
$args = array(
'explode_delimiter' => array(
'label' => 'Delimiter',
'type' => 'text',
'default' => ',',
),
@ihslimn
ihslimn / code.php
Last active November 17, 2023 09:28
Nth_Level_Terms_Macro
<?php
add_action( 'jet-engine/register-macros', function(){
class Nth_Level_Terms_Macro extends \Jet_Engine_Base_Macros {
public function macros_tag() {
return 'nth_level_terms';
}