Created
November 20, 2023 12:04
-
-
Save ihslimn/035bdf88c0b74bcac62752b54266e65d to your computer and use it in GitHub Desktop.
JetEngine Explode String callback
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 | |
add_action( 'jet-engine/callbacks/register', function( $callbacks ) { | |
$args = array( | |
'explode_delimiter' => array( | |
'label' => 'Delimiter', | |
'type' => 'text', | |
'default' => ',', | |
), | |
); | |
$callbacks->register_callback( 'jec_explode_string', 'Explode String', $args ); | |
function jec_explode_string( $string, $delimiter = ',' ) { | |
if ( empty( $delimiter ) && ! is_scalar( $string ) ) { | |
return $string; | |
} | |
return explode( $delimiter, $string ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment