Adding to functions.php

I was told I should add this to my functions.php file, but I don’t seem to see one. Is there one in X theme?

<?php add_filter( 'gform_replace_merge_tags', 'djb_gform_replace_merge_tags', 10, 7 ); /** * Replace custom merge tags. * * @link https://www.gravityhelp.com/documentation/article/gform_replace_merge_tags/ * * @param string $text Current text in which merge tags are being replaced. * @param object $form Current Form object. * @param object $entry Current Entry object. * @param boolean $url_encode Whether or not to encode any URLs found in the replaced value. * @param boolean $esc_html Whether or not to encode HTML found in the replaced value. * @param boolean $nl2br Whether or not to convert newlines to break tags. * @param string $format Determines how the value should be formatted. Default is html. * @return string Modified data. */ function djb_gform_replace_merge_tags( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format ) { if ( strpos( $text, '{current_hour}' ) !== false ) { $text = str_replace( '{current_hour}', current_time( 'g' ), $text ); } if ( strpos( $text, '{current_minute}' ) !== false ) { $text = str_replace( '{current_minute}', current_time( 'i' ), $text ); } if ( strpos( $text, '{current_am_pm}' ) !== false ) { $text = str_replace( '{current_am_pm}', current_time( 'A' ), $text ); } return $text; }

Hi there,

You will have to add this in the functions.php file of the child theme.

You can do this by logging in through through FTP (after you have installed and activated the child theme) then go to wp-content/themes/x-child, you should see the functions.php file there.

Edit the file and add this code

add_filter( 'gform_replace_merge_tags', 'djb_gform_replace_merge_tags', 10, 7 );
/**
* Replace custom merge tags.
*
* @link https://www.gravityhelp.com/documentation/article/gform_replace_merge_tags/
*
* @param string $text Current text in which merge tags are being replaced.
* @param object $form Current Form object.
* @param object $entry Current Entry object.
* @param boolean $url_encode Whether or not to encode any URLs found in the replaced value.
* @param boolean $esc_html Whether or not to encode HTML found in the replaced value.
* @param boolean $nl2br Whether or not to convert newlines to break tags.
* @param string $format Determines how the value should be formatted. Default is html.
* @return string Modified data.
*/
function djb_gform_replace_merge_tags( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format ) {
if ( strpos( $text, '{current_hour}' ) !== false ) {
$text = str_replace( '{current_hour}', current_time( 'g' ), $text );
}
if ( strpos( $text, '{current_minute}' ) !== false ) {
$text = str_replace( '{current_minute}', current_time( 'i' ), $text );
}
if ( strpos( $text, '{current_am_pm}' ) !== false ) {
$text = str_replace( '{current_am_pm}', current_time( 'A' ), $text );
}
return $text;
}

Right below :

// Additional Functions
// =============================================================================

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.