PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 6/* Shortcode handler */
 7
 8add_action( 'wpcf7_init', 'wpcf7_add_shortcode_submit' );
 9
10function wpcf7_add_shortcode_submit() {
11	wpcf7_add_shortcode( 'submit', 'wpcf7_submit_shortcode_handler' );
12}
13
14function wpcf7_submit_shortcode_handler( $tag ) {
15	$tag = new WPCF7_Shortcode( $tag );
16
17	$class = wpcf7_form_controls_class( $tag->type );
18
19	$atts = array();
20
21	$atts['class'] = $tag->get_class_option( $class );
22	$atts['id'] = $tag->get_id_option();
23	$atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
24
25	$value = isset( $tag->values[0] ) ? $tag->values[0] : '';
26
27	if ( empty( $value ) )
28		$value = __( 'Send', 'contact-form-7' );
29
30	$atts['type'] = 'submit';
31	$atts['value'] = $value;
32
33	$atts = wpcf7_format_atts( $atts );
34
35	$html = sprintf( '<input %1$s />', $atts );
36
37	return $html;
38}
39
40
41/* Tag generator */
42
43add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_submit', 55 );
44
45function wpcf7_add_tag_generator_submit() {
46	$tag_generator = WPCF7_TagGenerator::get_instance();
47	$tag_generator->add( 'submit', __( 'submit', 'contact-form-7' ),
48		'wpcf7_tag_generator_submit', array( 'nameless' => 1 ) );
49}
50
51function wpcf7_tag_generator_submit( $contact_form, $args = '' ) {
52	$args = wp_parse_args( $args, array() );
53
54	$description = __( "Generate a form-tag for a submit button. For more details, see %s.", 'contact-form-7' );
55
56	$desc_link = wpcf7_link( __( 'http://contactform7.com/submit-button/', 'contact-form-7' ), __( 'Submit Button', 'contact-form-7' ) );
57
58?>
59<div class="control-box">
60<fieldset>
61<legend><?php echo sprintf( esc_html( $description ), $desc_link ); ?></legend>
62
63<table class="form-table">
64<tbody>
65	<tr>
66	<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-values' ); ?>"><?php echo esc_html( __( 'Label', 'contact-form-7' ) ); ?></label></th>
67	<td><input type="text" name="values" class="oneline" id="<?php echo esc_attr( $args['content'] . '-values' ); ?>" /></td>
68	</tr>
69
70	<tr>
71	<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php echo esc_html( __( 'Id attribute', 'contact-form-7' ) ); ?></label></th>
72	<td><input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-id' ); ?>" /></td>
73	</tr>
74
75	<tr>
76	<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php echo esc_html( __( 'Class attribute', 'contact-form-7' ) ); ?></label></th>
77	<td><input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-class' ); ?>" /></td>
78	</tr>
79
80</tbody>
81</table>
82</fieldset>
83</div>
84
85<div class="insert-box">
86	<input type="text" name="submit" class="tag code" readonly="readonly" onfocus="this.select()" />
87
88	<div class="submitbox">
89	<input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr( __( 'Insert Tag', 'contact-form-7' ) ); ?>" />
90	</div>
91</div>
92<?php
93}