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 / form.json
Last active September 4, 2024 11:21
Allow provider to add services for itself. You need to download these files. form.json you need to import with JetFormBuilder. snippet.json - with code snippets plugin
{"post_title":"Apply to service","post_content":"<!-- wp:jet-forms\/hidden-field {\"name\":\"provider_id\"} \/-->\n\n<!-- wp:jet-forms\/select-field {\"field_options_from\":\"posts\",\"field_options_post_type\":\"services\",\"name\":\"service_id\"} \/-->\n\n<!-- wp:jet-forms\/submit-field \/-->","meta_input":{"_gspb_post_css":"","_jf_actions":"[{\"id\":3775,\"settings\":{\"send_email\":{\"subject\":\"New order on website\",\"content\":\"Hi admin!\\n\\nThere are new order on your website.\\n\\nOrder details:\\n- Post ID: %post_id%\"},\"call_hook\":{\"hook_name\":\"apply-to-service\"}},\"type\":\"call_hook\",\"conditions\":[],\"events\":[]}]"}}
@MjHead
MjHead / jet-theme-core-change-template.php
Created June 2, 2023 07:51
Change template for JetThemeCore plugin based on the option value.
<?php
add_filter( 'jet-theme-core/location/render/template-id', function( $template_id ) {
/**
* 123 - is ID of initial template you set in ThemeCore (could be found in adress bar)
* 'alternate-value' - is value of option which enables alternative layout for this page
* page-slug and option-name - there are option page slug and option name itself which are responsible for layout
*/
if ( 123 === $template_id && 'alternate-value' === jet_engine()->listings->data->get_option( 'page-slug::option-name' ) ) {
<?php
add_filter( 'jet-form-builder/form-handler/form-data', function( $request ) {
if ( isset( $request['field_name_to_sanitize'] ) ) {
$request['field_name_to_sanitize'] = wp_strip_all_tags( $request['field_name_to_sanitize'] );
}
return $request;
} );
@MjHead
MjHead / rest-api-terms-with-labels.php
Last active September 5, 2024 12:00
WordPress Rest API. Add post terms with labels to API response
<?php
/**
* Add this code without opening PHP tag into funcitons.php og your active theme or with any code snippets plugin
*/
add_action(
'rest_api_init',
function() {
/**
* Here you can set taxonomies slugs you wnat to add to Rest API response
@MjHead
MjHead / featured-media-url.php
Last active September 6, 2024 08:46
WordPress REST API. Add featured image to REST API response
@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 );