/wp-content/plugins/contact-form-7/modules/submit.php

https://gitlab.com/vovanduc/dainghia · PHP · 93 lines · 61 code · 27 blank · 5 comment · 2 complexity · 294287dfca790843328ff550a7d34aeb MD5 · raw file

  1. <?php
  2. /**
  3. ** A base module for [submit]
  4. **/
  5. /* Shortcode handler */
  6. add_action( 'wpcf7_init', 'wpcf7_add_shortcode_submit' );
  7. function wpcf7_add_shortcode_submit() {
  8. wpcf7_add_shortcode( 'submit', 'wpcf7_submit_shortcode_handler' );
  9. }
  10. function wpcf7_submit_shortcode_handler( $tag ) {
  11. $tag = new WPCF7_Shortcode( $tag );
  12. $class = wpcf7_form_controls_class( $tag->type );
  13. $atts = array();
  14. $atts['class'] = $tag->get_class_option( $class );
  15. $atts['id'] = $tag->get_id_option();
  16. $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
  17. $value = isset( $tag->values[0] ) ? $tag->values[0] : '';
  18. if ( empty( $value ) )
  19. $value = __( 'Send', 'contact-form-7' );
  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 );
  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( __( 'http://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. }