submit.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. ** A base module for [submit]
  4. **/
  5. /* form_tag handler */
  6. add_action( 'wpcf7_init', 'wpcf7_add_form_tag_submit', 10, 0 );
  7. function wpcf7_add_form_tag_submit() {
  8. wpcf7_add_form_tag( 'submit', 'wpcf7_submit_form_tag_handler' );
  9. }
  10. function wpcf7_submit_form_tag_handler( $tag ) {
  11. $class = wpcf7_form_controls_class( $tag->type );
  12. $atts = array();
  13. $atts['class'] = $tag->get_class_option( $class );
  14. $atts['id'] = $tag->get_id_option();
  15. $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
  16. $value = isset( $tag->values[0] ) ? $tag->values[0] : '';
  17. if ( empty( $value ) ) {
  18. $value = __( 'Send', 'contact-form-7' );
  19. }
  20. $atts['type'] = 'submit';
  21. $atts['value'] = $value;
  22. $atts = wpcf7_format_atts( $atts );
  23. $html = sprintf( '<input %1$s />', $atts );
  24. return $html;
  25. }
  26. /* Tag generator */
  27. add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_submit', 55, 0 );
  28. function wpcf7_add_tag_generator_submit() {
  29. $tag_generator = WPCF7_TagGenerator::get_instance();
  30. $tag_generator->add( 'submit', __( 'submit', 'contact-form-7' ),
  31. 'wpcf7_tag_generator_submit', array( 'nameless' => 1 ) );
  32. }
  33. function wpcf7_tag_generator_submit( $contact_form, $args = '' ) {
  34. $args = wp_parse_args( $args, array() );
  35. $description = __( "Generate a form-tag for a submit button. For more details, see %s.", 'contact-form-7' );
  36. $desc_link = wpcf7_link( __( 'https://contactform7.com/submit-button/', 'contact-form-7' ), __( 'Submit Button', 'contact-form-7' ) );
  37. ?>
  38. <div class="control-box">
  39. <fieldset>
  40. <legend><?php echo sprintf( esc_html( $description ), $desc_link ); ?></legend>
  41. <table class="form-table">
  42. <tbody>
  43. <tr>
  44. <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-values' ); ?>"><?php echo esc_html( __( 'Label', 'contact-form-7' ) ); ?></label></th>
  45. <td><input type="text" name="values" class="oneline" id="<?php echo esc_attr( $args['content'] . '-values' ); ?>" /></td>
  46. </tr>
  47. <tr>
  48. <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php echo esc_html( __( 'Id attribute', 'contact-form-7' ) ); ?></label></th>
  49. <td><input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-id' ); ?>" /></td>
  50. </tr>
  51. <tr>
  52. <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php echo esc_html( __( 'Class attribute', 'contact-form-7' ) ); ?></label></th>
  53. <td><input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-class' ); ?>" /></td>
  54. </tr>
  55. </tbody>
  56. </table>
  57. </fieldset>
  58. </div>
  59. <div class="insert-box">
  60. <input type="text" name="submit" class="tag code" readonly="readonly" onfocus="this.select()" />
  61. <div class="submitbox">
  62. <input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr( __( 'Insert Tag', 'contact-form-7' ) ); ?>" />
  63. </div>
  64. </div>
  65. <?php
  66. }