Skip to content

Instantly share code, notes, and snippets.

View MjHead's full-sized avatar

Andrew Shevchenko MjHead

  • Crocoblock
  • Ukraine
View GitHub Profile
@MjHead
MjHead / booking-calendar-api-doc.md
Created February 9, 2023 11:10 — forked from Crocoblock/booking-calendar-api-doc.md
JetBooking. JavaScript API documentation

Documentation for JetBooking calendar JS API!

Filter jet-booking/input/config

Allows to change initial set up of booking calendar. Usage example:

window.jetBookingState.filters.add( "jet-booking/input/config", ( config ) => {

	const validateDay = config.beforeShowDay;
@MjHead
MjHead / jet-engine-get-link-callback.php
Created December 8, 2022 14:28
JetEngine. Dynamic Field callback to get link from combination of 2 meta fields - fro label and URL
<?php
add_action( 'wp_footer', function() {
echo '<script>
jQuery( document ).on( "jet-booking/init-field", ( $event, $field ) => {
var silent = false;
var format = $field.data( "format" ) || "YYYY-MM-DD";
$field.bind( "datepicker-change", ( event, obj ) => {
silent = ! silent;
if ( silent ) {
$field.data( "dateRangePicker" ).setEnd( moment( obj.date1 ).add( 7, "d" ).format( "YYYY-MM-DD" ) );
@MjHead
MjHead / advanced-related-items-list.php
Created August 17, 2022 09:54
Adds custom callback for Dynamic Field widget from JetEngine to output related items list with thumbnails
@MjHead
MjHead / get-realtion-meta.php
Created August 17, 2022 07:59
Get meta data from JetEngine relations from the code
<?php
$rel_id = 111; // Set here your actual Relation ID. You can get it from an address bar on relation settings edit page
$relation = jet_engine()->relations->get_active_relations( $rel_id );
$parent_id = 111; // ID of prequired arent object from relation
$child_id = 111; // ID of prequired arent object from relation
$key = 'meta_key'; // Name/ID of meta field to get
$meta_value = $relation->get_meta( $parent_id, $child_id, $key );
@MjHead
MjHead / validate-cct-item.php
Created August 15, 2022 15:53
Insert new CCT item with JetFormBuilder only if similar item not exists
<?php
/**
* 1. Add action Hook before Insert/update CCT, set 'validate-cct' as hook name - https://i.imgur.com/48wcTA4.png
* 2. Replace 'tournaments' with your actual CCT slug
* 3. Replace 'name' with actual parameters to find similar items
*/
add_filter( 'jet-form-builder/custom-filter/validate-cct', function( $result, $request, $action ) {
$cct_slug = 'tournaments';
$cct = \Jet_Engine\Modules\Custom_Content_Types\Module::instance()->manager->get_content_types( $cct_slug );
<?php
namespace Jet_Engine\Query_Builder\Queries;
// put this file into jet-engine\includes\components\query-builder\queries\ and replace initial file
// this comment is actual until 3.0.3 version
abstract class Base_Query {
public $id = false;
public $name = false;
@MjHead
MjHead / base-arg.php
Last active June 3, 2022 10:18
JSF dynamic query args prototype
<?php
// Base arg class. all args must extend it
abstract class Base_Arg {
// returns main arg
abstract public function get_arg();
// returns main arg label for UI control
abstract public function get_name();
@MjHead
MjHead / jet-form-builder-custom-preset.php
Created May 27, 2022 15:39
JetFormBuilder. Use custom data as default value
<?php
add_action( 'init', function() {
// Check if need to do an API request
if ( empty( $_GET['test_api_request'] ) ) {
return;
}
// get remote data
@MjHead
MjHead / ajax-listing-url.php
Created February 2, 2022 11:21
JetEngine. Replace URL of ajax callback to get Listing items
<?php
add_filter( 'jet-engine/listings/ajax-listing-url', function( $url ) {
return esc_url( admin_url( 'admin-ajax.php' ) );
} );