Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Last active February 6, 2018 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredatch/c60a807a340eeaf6039df3f3cde219d5 to your computer and use it in GitHub Desktop.
Save jaredatch/c60a807a340eeaf6039df3f3cde219d5 to your computer and use it in GitHub Desktop.
WPForms register/create new smart tag
<?php
/**
* Registers the Request URI smart tag.
*
* @param array $tags
* @return array
*/
function wpf_smarttag_request_uri_register( $tags ) {
$tags['request_uri'] = 'Request URI';
return $tags;
}
add_filter( 'wpforms_smart_tags', 'wpf_smarttag_request_uri_register' );
/**
* Processes the Request URI smart tag.
*
* @param string
* @param array $tags
* @return string
*/
function wp_smarttag_request_uri_process( $content, $tag ) {
$request = esc_url( remove_query_arg( 'placeholderarg' ) );
return str_replace( '{request_uri}', $request, $content );
}
add_filter( 'wpforms_smart_tag_process', 'wp_smarttag_request_uri_process', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment