Line | |
---|
1 | <?php
|
---|
2 | /**
|
---|
3 | ** A base module for [submit]
|
---|
4 | **/
|
---|
5 |
|
---|
6 | /* Shortcode handler */
|
---|
7 |
|
---|
8 | function wpcf7_submit_shortcode_handler( $tag ) {
|
---|
9 | if ( ! is_array( $tag ) )
|
---|
10 | return '';
|
---|
11 |
|
---|
12 | $options = (array) $tag['options'];
|
---|
13 | $values = (array) $tag['values'];
|
---|
14 |
|
---|
15 | $atts = '';
|
---|
16 | $id_att = '';
|
---|
17 | $class_att = '';
|
---|
18 |
|
---|
19 | foreach ( $options as $option ) {
|
---|
20 | if ( preg_match( '%^id:([-0-9a-zA-Z_]+)$%', $option, $matches ) ) {
|
---|
21 | $id_att = $matches[1];
|
---|
22 |
|
---|
23 | } elseif ( preg_match( '%^class:([-0-9a-zA-Z_]+)$%', $option, $matches ) ) {
|
---|
24 | $class_att .= ' ' . $matches[1];
|
---|
25 |
|
---|
26 | }
|
---|
27 | }
|
---|
28 |
|
---|
29 | if ( $id_att )
|
---|
30 | $atts .= ' id="' . trim( $id_att ) . '"';
|
---|
31 |
|
---|
32 | if ( $class_att )
|
---|
33 | $atts .= ' class="' . trim( $class_att ) . '"';
|
---|
34 |
|
---|
35 | $value = $values[0];
|
---|
36 | if ( empty( $value ) )
|
---|
37 | $value = __( 'Send', 'wpcf7' );
|
---|
38 |
|
---|
39 | $ajax_loader_image_url = wpcf7_plugin_url( 'images/ajax-loader.gif' );
|
---|
40 |
|
---|
41 | $html = '<input type="submit" value="' . esc_attr( $value ) . '"' . $atts . ' />';
|
---|
42 | $html .= ' <img class="ajax-loader" style="visibility: hidden;" alt="ajax loader" src="' . $ajax_loader_image_url . '" />';
|
---|
43 |
|
---|
44 | return $html;
|
---|
45 | }
|
---|
46 |
|
---|
47 | wpcf7_add_shortcode( 'submit', 'wpcf7_submit_shortcode_handler' );
|
---|
48 |
|
---|
49 | ?> |
---|
Note:
See
TracBrowser
for help on using the repository browser.