Skip to content

Instantly share code, notes, and snippets.

@Crocoblock
Created July 17, 2026 14:25
Show Gist options
  • Select an option

  • Save Crocoblock/2af1fa5ab01fbefb6001428b714ccd0c to your computer and use it in GitHub Desktop.

Select an option

Save Crocoblock/2af1fa5ab01fbefb6001428b714ccd0c to your computer and use it in GitHub Desktop.
URL contains macro
<?php
add_action( 'jet-engine/register-macros', function() {
class URL_Contains extends \Jet_Engine_Base_Macros {
public function macros_tag() {
return 'url_contains';
}
public function macros_name() {
return 'URL Contains';
}
public function macros_args() {
return array(
'needle' => array(
'label' => 'Text to search',
'type' => 'text',
'default' => '',
),
);
}
public function macros_callback( $args = array() ) {
$needle = ! empty( $args['needle'] ) ? $args['needle'] : '';
if ( empty( $needle ) ) {
return 0;
}
$request_uri = $_SERVER['REQUEST_URI'] ?? '';
return strpos( $request_uri, $needle ) !== false ? 1 : 0;
}
}
new URL_Contains();
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment