submission ); } /** * Searches input for tags {field:FIELD_NAME} and replaces with field values * * @since 1.0.1 * */ function af_resolve_field_includes( $input, $fields = false ) { // Get fields from the global submission object if fields weren't passed if ( ! $fields && af_has_submission() ) { $fields = AF()->submission['fields']; } if ( preg_match_all( "/{field:(.*?)}/", $input, $matches ) ) { foreach ($matches[1] as $i => $field) { $field_value = af_get_field( $field, $fields ); if ( is_array( $field_value ) ) { $include_value = join( ', ', $field_value ); } else { $include_value = (string)$field_value; } $input = str_replace( $matches[0][$i], $include_value, $input ); } } return $input; } /** * Checks if the passed key is a valid form key (begins with form_) * * @since 1.0.1 * */ function af_is_valid_form_key( $key ) { if ( ! is_string( $key ) ) { return false; } if ( 'form_' == substr( $key, 0, 5 ) ) { return true; } return false; } /** * Output an "Insert field" button populated with $fields * $floating adds class "floating" to the wrapper making the button float right in an input field * * @since 1.1.1 * */ function _af_field_inserter_button( $fields, $floating = false ) { $classses = ( $floating ) ? 'floating' : ''; echo 'Insert field'; echo '
'; foreach ( $fields as $field ) { echo sprintf( '
%s
', $field['name'], $field['label'] ); } echo '
'; echo '
'; }