Fix wc_voucher cart calulation

function custom_voucher_discount_type( $discount, $discounting_amount, $cart_item, $single, $coupon ) { global $wpdb; // Check if the coupon is a wc_voucher $voucher_post_id = $wpdb->get_var($wpdb->prepare( “SELECT ID FROM {$wpdb->posts} WHERE post_title = %s AND post_type = ‘wc_voucher’”, $coupon->get_code() )); if ( $voucher_post_id )…Continue reading

validador de CPF – JetFormBuilder

/** * verifica se o cpf informado é valido */ function jet_fb_v_validacpf( $value, $context ): bool { $fields = jet_fb_request_handler()->get_request(); // Extrai somente os números $cpf = preg_replace( ‘/[^0-9]/is’, ”, $fields[‘cpf’] ); // Verifica se foi informado todos os digitos…Continue reading

CPF Cadastro único – JetFormBuilder

use Jet_Form_Builder\Exceptions\Action_Exception; add_action( ‘jet-form-builder/custom-action/uniquecpf’, function ( $request, $handler ) { $usuario_atual_id = get_current_user_id(); // Verificar se o usuário atual está logado e tem o mesmo CPF if ($usuario_atual_id && get_user_meta($usuario_atual_id, ‘jet_user_cpf’, true) === $request[‘cpf’]) { // Pula a validação se…Continue reading

WP Simple Pay: Localize Recurring Dates

add_filter( ‘simpay_payment_confirmation_template_tag_charge-date’, function( $value ) { return date_i18n( get_option( ‘date_format’ ), strtotime( $value ) ); }, 20 ); add_filter( ‘simpay_payment_confirmation_template_tag_next-invoice-date’, function( $value ) { return date_i18n( get_option( ‘date_format’ ), strtotime( $value ) ); }, 20 );Continue reading

Completely Disable Comments

add_action(‘admin_init’, function () { // Redirect any user trying to access comments page global $pagenow; if ($pagenow === ‘edit-comments.php’) { wp_safe_redirect(admin_url()); exit; } // Remove comments metabox from dashboard remove_meta_box(‘dashboard_recent_comments’, ‘dashboard’, ‘normal’); // Disable support for comments and trackbacks in…Continue reading

Advanced Spam Filters for Elementor Forms

/** START ELEMENTOR FORM SPAM PROTECTION **/ add_action( ‘elementor_pro/forms/validation’, function ( $record, $handler ) { // Make sure the form is an instance of Form_Record class if ( ! $record instanceof \ElementorPro\Modules\Forms\Classes\Form_Record ) { return; } $raw_fields = $record->get(‘fields’); $fields…Continue reading

WPForms Smart Tags – Birth Date

/** * Register the Smart Tag so it will be available to select in the form builder. * * @link https://wpforms.com/developers/how-to-create-a-custom-smart-tag/ */ function wpf_dev_register_smarttag_birth_date( $tags ) { // Key is the tag, item is the tag name. $tags[ ‘birth_date’ ]…Continue reading