acceptance.php
15 years ago
akismet.php
14 years ago
captcha.php
15 years ago
checkbox.php
15 years ago
file.php
14 years ago
quiz.php
15 years ago
response.php
15 years ago
select.php
14 years ago
special-mail-tags.php
14 years ago
submit.php
15 years ago
text.php
15 years ago
textarea.php
14 years ago
submit.php
97 lines
| 1 | <?php |
| 2 | /** |
| 3 | ** A base module for [submit] |
| 4 | **/ |
| 5 | |
| 6 | /* Shortcode handler */ |
| 7 | |
| 8 | wpcf7_add_shortcode( 'submit', 'wpcf7_submit_shortcode_handler' ); |
| 9 | |
| 10 | function wpcf7_submit_shortcode_handler( $tag ) { |
| 11 | if ( ! is_array( $tag ) ) |
| 12 | return ''; |
| 13 | |
| 14 | $options = (array) $tag['options']; |
| 15 | $values = (array) $tag['values']; |
| 16 | |
| 17 | $atts = ''; |
| 18 | $id_att = ''; |
| 19 | $class_att = ''; |
| 20 | $tabindex_att = ''; |
| 21 | |
| 22 | $class_att .= ' wpcf7-submit'; |
| 23 | |
| 24 | foreach ( $options as $option ) { |
| 25 | if ( preg_match( '%^id:([-0-9a-zA-Z_]+)$%', $option, $matches ) ) { |
| 26 | $id_att = $matches[1]; |
| 27 | |
| 28 | } elseif ( preg_match( '%^class:([-0-9a-zA-Z_]+)$%', $option, $matches ) ) { |
| 29 | $class_att .= ' ' . $matches[1]; |
| 30 | |
| 31 | } elseif ( preg_match( '%^tabindex:(\d+)$%', $option, $matches ) ) { |
| 32 | $tabindex_att = (int) $matches[1]; |
| 33 | |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | if ( $id_att ) |
| 38 | $atts .= ' id="' . trim( $id_att ) . '"'; |
| 39 | |
| 40 | if ( $class_att ) |
| 41 | $atts .= ' class="' . trim( $class_att ) . '"'; |
| 42 | |
| 43 | if ( '' !== $tabindex_att ) |
| 44 | $atts .= sprintf( ' tabindex="%d"', $tabindex_att ); |
| 45 | |
| 46 | $value = isset( $values[0] ) ? $values[0] : ''; |
| 47 | if ( empty( $value ) ) |
| 48 | $value = __( 'Send', 'wpcf7' ); |
| 49 | |
| 50 | $html = '<input type="submit" value="' . esc_attr( $value ) . '"' . $atts . ' />'; |
| 51 | |
| 52 | if ( wpcf7_script_is() ) { |
| 53 | $src = apply_filters( 'wpcf7_ajax_loader', wpcf7_plugin_url( 'images/ajax-loader.gif' ) ); |
| 54 | $html .= '<img class="ajax-loader" style="visibility: hidden;" alt="' . esc_attr( __( 'Sending ...', 'wpcf7' ) ) . '" src="' . esc_url_raw( $src ) . '" />'; |
| 55 | } |
| 56 | |
| 57 | return $html; |
| 58 | } |
| 59 | |
| 60 | |
| 61 | /* Tag generator */ |
| 62 | |
| 63 | add_action( 'admin_init', 'wpcf7_add_tag_generator_submit', 55 ); |
| 64 | |
| 65 | function wpcf7_add_tag_generator_submit() { |
| 66 | wpcf7_add_tag_generator( 'submit', __( 'Submit button', 'wpcf7' ), |
| 67 | 'wpcf7-tg-pane-submit', 'wpcf7_tg_pane_submit', array( 'nameless' => 1 ) ); |
| 68 | } |
| 69 | |
| 70 | function wpcf7_tg_pane_submit( &$contact_form ) { |
| 71 | ?> |
| 72 | <div id="wpcf7-tg-pane-submit" class="hidden"> |
| 73 | <form action=""> |
| 74 | <table> |
| 75 | <tr> |
| 76 | <td><code>id</code> (<?php echo esc_html( __( 'optional', 'wpcf7' ) ); ?>)<br /> |
| 77 | <input type="text" name="id" class="idvalue oneline option" /></td> |
| 78 | |
| 79 | <td><code>class</code> (<?php echo esc_html( __( 'optional', 'wpcf7' ) ); ?>)<br /> |
| 80 | <input type="text" name="class" class="classvalue oneline option" /></td> |
| 81 | </tr> |
| 82 | |
| 83 | <tr> |
| 84 | <td><?php echo esc_html( __( 'Label', 'wpcf7' ) ); ?> (<?php echo esc_html( __( 'optional', 'wpcf7' ) ); ?>)<br /> |
| 85 | <input type="text" name="values" class="oneline" /></td> |
| 86 | |
| 87 | <td></td> |
| 88 | </tr> |
| 89 | </table> |
| 90 | |
| 91 | <div class="tg-tag"><?php echo esc_html( __( "Copy this code and paste it into the form left.", 'wpcf7' ) ); ?><br /><input type="text" name="submit" class="tag" readonly="readonly" onfocus="this.select()" /></div> |
| 92 | </form> |
| 93 | </div> |
| 94 | <?php |
| 95 | } |
| 96 | |
| 97 | ?> |