wpcf7_tag_generator_checkbox

The Contact Form 7 wpcf7 tag generator checkbox function.

Description

wpcf7_tag_generator_checkbox( $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_checkbox' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7/modules/checkbox.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_checkbox($contact_form, $args); 
  12.  

Defined (1)

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

/modules/checkbox.php  
  1. function wpcf7_tag_generator_checkbox( $contact_form, $args = '' ) { 
  2. $args = wp_parse_args( $args, array() ); 
  3. $type = $args['id']; 
  4.  
  5. if ( 'radio' != $type ) { 
  6. $type = 'checkbox'; 
  7.  
  8. if ( 'checkbox' == $type ) { 
  9. $description = __( "Generate a form-tag for a group of checkboxes. For more details, see %s.", 'contact-form-7' ); 
  10. } elseif ( 'radio' == $type ) { 
  11. $description = __( "Generate a form-tag for a group of radio buttons. For more details, see %s.", 'contact-form-7' ); 
  12.  
  13. $desc_link = wpcf7_link( __( 'http://contactform7.com/checkboxes-radio-buttons-and-menus/', 'contact-form-7' ), __( 'Checkboxes, Radio Buttons and Menus', 'contact-form-7' ) ); 
  14.  
  15. ?> 
  16. <div class="control-box"> 
  17. <fieldset> 
  18. <legend><?php echo sprintf( esc_html( $description ), $desc_link ); ?></legend> 
  19.  
  20. <table class="form-table"> 
  21. <tbody> 
  22. <?php if ( 'checkbox' == $type ) : ?> 
  23. <tr> 
  24. <th scope="row"><?php echo esc_html( __( 'Field type', 'contact-form-7' ) ); ?></th> 
  25. <td> 
  26. <fieldset> 
  27. <legend class="screen-reader-text"><?php echo esc_html( __( 'Field type', 'contact-form-7' ) ); ?></legend> 
  28. <label><input type="checkbox" name="required" /> <?php echo esc_html( __( 'Required field', 'contact-form-7' ) ); ?></label> 
  29. </fieldset> 
  30. </td> 
  31. </tr> 
  32. <?php endif; ?> 
  33.  
  34. <tr> 
  35. <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php echo esc_html( __( 'Name', 'contact-form-7' ) ); ?></label></th> 
  36. <td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /></td> 
  37. </tr> 
  38.  
  39. <tr> 
  40. <th scope="row"><?php echo esc_html( __( 'Options', 'contact-form-7' ) ); ?></th> 
  41. <td> 
  42. <fieldset> 
  43. <legend class="screen-reader-text"><?php echo esc_html( __( 'Options', 'contact-form-7' ) ); ?></legend> 
  44. <textarea name="values" class="values" id="<?php echo esc_attr( $args['content'] . '-values' ); ?>"></textarea> 
  45. <label for="<?php echo esc_attr( $args['content'] . '-values' ); ?>"><span class="description"><?php echo esc_html( __( "One option per line.", 'contact-form-7' ) ); ?></span></label><br /> 
  46. <label><input type="checkbox" name="label_first" class="option" /> <?php echo esc_html( __( 'Put a label first, a checkbox last', 'contact-form-7' ) ); ?></label><br /> 
  47. <label><input type="checkbox" name="use_label_element" class="option" /> <?php echo esc_html( __( 'Wrap each item with label element', 'contact-form-7' ) ); ?></label> 
  48. <?php if ( 'checkbox' == $type ) : ?> 
  49. <br /><label><input type="checkbox" name="exclusive" class="option" /> <?php echo esc_html( __( 'Make checkboxes exclusive', 'contact-form-7' ) ); ?></label> 
  50. <?php endif; ?> 
  51. </fieldset> 
  52. </td> 
  53. </tr> 
  54.  
  55. <tr> 
  56. <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php echo esc_html( __( 'Id attribute', 'contact-form-7' ) ); ?></label></th> 
  57. <td><input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-id' ); ?>" /></td> 
  58. </tr> 
  59.  
  60. <tr> 
  61. <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php echo esc_html( __( 'Class attribute', 'contact-form-7' ) ); ?></label></th> 
  62. <td><input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-class' ); ?>" /></td> 
  63. </tr> 
  64.  
  65. </tbody> 
  66. </table> 
  67. </fieldset> 
  68. </div> 
  69.  
  70. <div class="insert-box"> 
  71. <input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()" /> 
  72.  
  73. <div class="submitbox"> 
  74. <input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr( __( 'Insert Tag', 'contact-form-7' ) ); ?>" /> 
  75. </div> 
  76.  
  77. <br class="clear" /> 
  78.  
  79. <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> 
  80. </div> 
  81. <?php