Last active
February 6, 2018 03:58
-
-
Save jaredatch/c60a807a340eeaf6039df3f3cde219d5 to your computer and use it in GitHub Desktop.
WPForms register/create new smart tag
This file contains 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 | |
/** | |
* 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