Skip to content

Instantly share code, notes, and snippets.

@LaxusCroco
LaxusCroco / send_emails_bcc.php
Created September 20, 2023 11:31
Send all emails on the site as bcc. To make the snippet work, the subject field of the email should contain <bcc:emails>
<?php
add_filter( 'wp_mail', function( $args ) {
if ( false === strpos( $args['subject'], '<bcc:emails>' ) ) {
return $args;
}
$email = $args['to'];
@LaxusCroco
LaxusCroco / disable-woo-checkout-for-service.php
Created September 20, 2023 11:52
Replace the ID of the service in $to_skip = array( 164 ); and $to_skip = array( 13723 ); with the needed service ID.
<?php
//update appointment status
function __complete_appointment( $appointment_id ) {
if ( ! isset( $appointment_id ) ) {
return;
}
$appointment = jet_apb()->db->get_appointment_by( 'ID', $appointment_id );
if ( ! $appointment ) {
return;
<?php
add_action( 'jet-engine/register-macros', function() {
class Get_Store_REGEXP extends Jet_Engine\Modules\Data_Stores\Macros\Get_Store {
public function macros_tag() {
return 'get_store_regexp';
}
@LaxusCroco
LaxusCroco / check_iss_pswd_unique.php
Created September 26, 2023 14:06
JetFormBuilder Check if user password matches entered password
<?php
/**
* To get all the values of the fields in the form, you can use the expression:
* jet_fb_request_handler()->get_request() or $context->get_request()
\*
* If the field is located in the middle of the repeater, then only
* jet_fb_request_handler()->get_request(), but $context->get_request()
* will return the values of all fields of the current repeater element
\*
@LaxusCroco
LaxusCroco / delete-old-appointments.php
Created September 28, 2023 13:24
This will ensure that the old appointments (the time of which has passed) are deleted daily.
<?php
add_action( 'init', function() {
if ( ! function_exists( 'jet_apb' ) ) {
return;
}
if ( ! wp_next_scheduled( 'delete_old_appointments' ) ) {
wp_schedule_event( time(), 'daily', 'delete_old_appointments' );
@LaxusCroco
LaxusCroco / disable_paylater.php
Last active November 2, 2023 12:41
Remove paylater and monthly options in the PayPal payment gateway
<?php
add_action(
'jet-form-builder/gateways/before-create',
function ( $rest_action ) {
if ( ! is_a(
$rest_action,
\JFB_Modules\Gateways\Paypal\Api_Actions\Pay_Now_Action::class
) ) {
return;
@LaxusCroco
LaxusCroco / Get_Query_Count_Macro.php
Created November 3, 2023 08:56
Get query count macro for Bricks
<?php
add_action( 'jet-engine/register-macros', function(){
class Get_Query_Count_Macro extends \Jet_Engine_Base_Macros {
public function macros_tag() {
return 'get_query_count';
}
@LaxusCroco
LaxusCroco / display_terms_in_ajax_search_meta.php
Created November 7, 2023 13:36
Adds the ability to display the name of the related term in the Custom Field area of Ajax Search. In the Key field, enter post_terms__category where the 'category' part should be replaced with the taxonomy slug.
<?php
add_filter( 'jet-search/template/pre-get-meta-field', function($value, $meta, $post){
$meta_key = $meta['meta_key'] ?? '';
if( false === strpos( $meta_key, 'post_terms__' ) ){
return $value;
}
$tax_slug = ( explode('post_terms__', $meta_key) )[1];
@LaxusCroco
LaxusCroco / disable_sanitize_output.php
Created November 8, 2023 13:25
Disable the sanitizing of the output in the Dynamic Field widget
<?php
add_filter( 'jet-engine/listings/dynamic-field/sanitize-output', '__return_false' );
@LaxusCroco
LaxusCroco / get_ancestor_macro.php
Created November 9, 2023 11:45
A macro which retrieves the top-level parent of the term attached to the current post.
<?php
add_action( 'jet-engine/register-macros', function(){
class Get_Ancestor extends \Jet_Engine_Base_Macros {
public function macros_tag() {
return 'get_ancestor';
}