Created
September 21, 2023 14:31
-
-
Save LaxusCroco/21b97a0a482494fef38cde8342c193fa to your computer and use it in GitHub Desktop.
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/register-macros', function() { | |
class Get_Store_REGEXP extends Jet_Engine\Modules\Data_Stores\Macros\Get_Store { | |
public function macros_tag() { | |
return 'get_store_regexp'; | |
} | |
public function macros_name() { | |
return 'Get store REGEXP'; | |
} | |
public function macros_args() { | |
return array( | |
'stores' => array( | |
'label' => 'Stores', | |
'type' => 'text', | |
), | |
); | |
} | |
public function macros_callback( $args = array() ) { | |
$data_store_slugs = $args['stores'] ?? ''; | |
if ( empty( $data_store_slugs ) ) { | |
return ''; | |
} | |
$results = array_map( function( $slug ) { | |
$ids = parent::macros_callback( array( 'store' => $slug ) ); | |
$ids = '"' . str_replace( ',', '"|"', $ids ) . '"'; | |
return $ids; | |
}, wp_parse_list( $data_store_slugs ) ); | |
return implode( '|', $results ); | |
} | |
} | |
new Get_Store_REGEXP(); | |
}, 1000 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment