wpcf7_tag_generator_text

The Contact Form 7 wpcf7 tag generator text function.

Description

wpcf7_tag_generator_text( $contact_form, (string) $args = '' ); 

Parameters (2)

0. $contact_form
The contact form.
1. $args — Optional. (string) => ''
The args.

Usage

  1. if ( !function_exists( 'wpcf7_tag_generator_text' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7/modules/text.php'; 
  3.  
  4. // The contact form. 
  5. $contact_form = null; 
  6.  
  7. // The args. 
  8. $args = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wpcf7_tag_generator_text($contact_form, $args); 
  12.  

Defined (1)

The function is defined in the following location(s).

/modules/text.php  
  1. function wpcf7_tag_generator_text( $contact_form, $args = '' ) { 
  2. $args = wp_parse_args( $args, array() ); 
  3. $type = $args['id']; 
  4.  
  5. if ( ! in_array( $type, array( 'email', 'url', 'tel' ) ) ) { 
  6. $type = 'text'; 
  7.  
  8. if ( 'text' == $type ) { 
  9. $description = __( "Generate a form-tag for a single-line plain text input field. For more details, see %s.", 'contact-form-7' ); 
  10. } elseif ( 'email' == $type ) { 
  11. $description = __( "Generate a form-tag for a single-line email address input field. For more details, see %s.", 'contact-form-7' ); 
  12. } elseif ( 'url' == $type ) { 
  13. $description = __( "Generate a form-tag for a single-line URL input field. For more details, see %s.", 'contact-form-7' ); 
  14. } elseif ( 'tel' == $type ) { 
  15. $description = __( "Generate a form-tag for a single-line telephone number input field. For more details, see %s.", 'contact-form-7' ); 
  16.  
  17. $desc_link = wpcf7_link( __( 'https://contactform7.com/text-fields/', 'contact-form-7' ), __( 'Text Fields', 'contact-form-7' ) ); 
  18.  
  19. ?> 
  20. <div class="control-box"> 
  21. <fieldset> 
  22. <legend><?php echo sprintf( esc_html( $description ), $desc_link ); ?></legend> 
  23.  
  24. <table class="form-table"> 
  25. <tbody> 
  26. <tr> 
  27. <th scope="row"><?php echo esc_html( __( 'Field type', 'contact-form-7' ) ); ?></th> 
  28. <td> 
  29. <fieldset> 
  30. <legend class="screen-reader-text"><?php echo esc_html( __( 'Field type', 'contact-form-7' ) ); ?></legend> 
  31. <label><input type="checkbox" name="required" /> <?php echo esc_html( __( 'Required field', 'contact-form-7' ) ); ?></label> 
  32. </fieldset> 
  33. </td> 
  34. </tr> 
  35.  
  36. <tr> 
  37. <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php echo esc_html( __( 'Name', 'contact-form-7' ) ); ?></label></th> 
  38. <td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /></td> 
  39. </tr> 
  40.  
  41. <tr> 
  42. <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-values' ); ?>"><?php echo esc_html( __( 'Default value', 'contact-form-7' ) ); ?></label></th> 
  43. <td><input type="text" name="values" class="oneline" id="<?php echo esc_attr( $args['content'] . '-values' ); ?>" /><br /> 
  44. <label><input type="checkbox" name="placeholder" class="option" /> <?php echo esc_html( __( 'Use this text as the placeholder of the field', 'contact-form-7' ) ); ?></label></td> 
  45. </tr> 
  46.  
  47. <?php if ( in_array( $type, array( 'text', 'email', 'url' ) ) ) : ?> 
  48. <tr> 
  49. <th scope="row"><?php echo esc_html( __( 'Akismet', 'contact-form-7' ) ); ?></th> 
  50. <td> 
  51. <fieldset> 
  52. <legend class="screen-reader-text"><?php echo esc_html( __( 'Akismet', 'contact-form-7' ) ); ?></legend> 
  53.  
  54. <?php if ( 'text' == $type ) : ?> 
  55. <label> 
  56. <input type="checkbox" name="akismet:author" class="option" /> 
  57. <?php echo esc_html( __( "This field requires author's name", 'contact-form-7' ) ); ?> 
  58. </label> 
  59. <?php elseif ( 'email' == $type ) : ?> 
  60. <label> 
  61. <input type="checkbox" name="akismet:author_email" class="option" /> 
  62. <?php echo esc_html( __( "This field requires author's email address", 'contact-form-7' ) ); ?> 
  63. </label> 
  64. <?php elseif ( 'url' == $type ) : ?> 
  65. <label> 
  66. <input type="checkbox" name="akismet:author_url" class="option" /> 
  67. <?php echo esc_html( __( "This field requires author's URL", 'contact-form-7' ) ); ?> 
  68. </label> 
  69. <?php endif; ?> 
  70.  
  71. </fieldset> 
  72. </td> 
  73. </tr> 
  74. <?php endif; ?> 
  75.  
  76. <tr> 
  77. <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php echo esc_html( __( 'Id attribute', 'contact-form-7' ) ); ?></label></th> 
  78. <td><input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-id' ); ?>" /></td> 
  79. </tr> 
  80.  
  81. <tr> 
  82. <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php echo esc_html( __( 'Class attribute', 'contact-form-7' ) ); ?></label></th> 
  83. <td><input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-class' ); ?>" /></td> 
  84. </tr> 
  85.  
  86. </tbody> 
  87. </table> 
  88. </fieldset> 
  89. </div> 
  90.  
  91. <div class="insert-box"> 
  92. <input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()" /> 
  93.  
  94. <div class="submitbox"> 
  95. <input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr( __( 'Insert Tag', 'contact-form-7' ) ); ?>" /> 
  96. </div> 
  97.  
  98. <br class="clear" /> 
  99.  
  100. <p class="description mail-tag"><label for="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>"><?php echo sprintf( esc_html( __( "To use the value input through this field in a mail field, you need to insert the corresponding mail-tag (%s) into the field on the Mail tab.", 'contact-form-7' ) ), '<strong><span class="mail-tag"></span></strong>' ); ?><input type="text" class="mail-tag code hidden" readonly="readonly" id="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>" /></label></p> 
  101. </div> 
  102. <?php