Created
November 17, 2023 16:20
-
-
Save LaxusCroco/65b8a6c072ac40c5f58a4a01e923f555 to your computer and use it in GitHub Desktop.
Use macros of JetEngine in the Default Value area of Hidden, Text, Date, Time, Datetime, Colorpicker, and Number fields.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class JFB_Do_Macros_In_Default { | |
public function __construct() { | |
add_action( 'plugins_loaded', array( $this, 'maybe_add_filter' ) ); | |
} | |
public function maybe_add_filter() { | |
if ( ! function_exists( 'jet_engine' ) ) { | |
return; | |
} | |
add_filter( 'jet-form-builder/render/text-field', array( $this, 'do_macros' ) ); | |
add_filter( 'jet-form-builder/render/date-field', array( $this, 'do_macros' ) ); | |
add_filter( 'jet-form-builder/render/time-field', array( $this, 'do_macros' ) ); | |
add_filter( 'jet-form-builder/render/hidden-field', array( $this, 'do_macros' ) ); | |
add_filter( 'jet-form-builder/render/number-field', array( $this, 'do_macros' ) ); | |
add_filter( 'jet-form-builder/render/datetime-field', array( $this, 'do_macros' ) ); | |
add_filter( 'jet-form-builder/render/color-picker-field', array( $this, 'do_macros' ) ); | |
} | |
public function do_macros( $args ) { | |
$args[ 'default' ] = jet_engine()->listings->macros->do_macros( $args[ 'default' ] ); | |
return $args; | |
} | |
} | |
new JFB_Do_Macros_In_Default(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment