akismet
11 months ago
constant-contact
9 months ago
recaptcha
9 months ago
sendinblue
9 months ago
stripe
9 months ago
turnstile
8 months ago
acceptance.php
11 months ago
checkbox.php
9 months ago
count.php
1 year ago
date.php
7 months ago
disallowed-list.php
9 months ago
doi-helper.php
4 years ago
file.php
11 months ago
flamingo.php
9 months ago
hidden.php
7 years ago
listo.php
2 years ago
number.php
7 months ago
quiz.php
11 months ago
really-simple-captcha.php
6 months ago
reflection.php
3 years ago
response.php
6 years ago
select.php
7 months ago
submit.php
11 months ago
text.php
7 months ago
textarea.php
7 months ago
submit.php
116 lines
| 1 | <?php |
| 2 | /** |
| 3 | ** A base module for [submit] |
| 4 | **/ |
| 5 | |
| 6 | /* form_tag handler */ |
| 7 | |
| 8 | add_action( 'wpcf7_init', 'wpcf7_add_form_tag_submit', 10, 0 ); |
| 9 | |
| 10 | function wpcf7_add_form_tag_submit() { |
| 11 | wpcf7_add_form_tag( 'submit', 'wpcf7_submit_form_tag_handler' ); |
| 12 | } |
| 13 | |
| 14 | function wpcf7_submit_form_tag_handler( $tag ) { |
| 15 | $class = wpcf7_form_controls_class( $tag->type, 'has-spinner' ); |
| 16 | |
| 17 | $atts = array(); |
| 18 | |
| 19 | $atts['class'] = $tag->get_class_option( $class ); |
| 20 | $atts['id'] = $tag->get_id_option(); |
| 21 | $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true ); |
| 22 | |
| 23 | $value = isset( $tag->values[0] ) ? $tag->values[0] : ''; |
| 24 | |
| 25 | if ( empty( $value ) ) { |
| 26 | $value = __( 'Send', 'contact-form-7' ); |
| 27 | } |
| 28 | |
| 29 | $atts['type'] = 'submit'; |
| 30 | $atts['value'] = $value; |
| 31 | |
| 32 | $atts = wpcf7_format_atts( $atts ); |
| 33 | |
| 34 | $html = sprintf( '<input %1$s />', $atts ); |
| 35 | |
| 36 | return $html; |
| 37 | } |
| 38 | |
| 39 | |
| 40 | /* Tag generator */ |
| 41 | |
| 42 | add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_submit', 55, 0 ); |
| 43 | |
| 44 | function wpcf7_add_tag_generator_submit() { |
| 45 | $tag_generator = WPCF7_TagGenerator::get_instance(); |
| 46 | |
| 47 | $tag_generator->add( 'submit', __( 'submit', 'contact-form-7' ), |
| 48 | 'wpcf7_tag_generator_submit', |
| 49 | array( 'version' => '2' ) |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | function wpcf7_tag_generator_submit( $contact_form, $options ) { |
| 54 | $field_types = array( |
| 55 | 'submit' => array( |
| 56 | 'display_name' => __( 'Submit button', 'contact-form-7' ), |
| 57 | 'heading' => __( 'Submit button form-tag generator', 'contact-form-7' ), |
| 58 | 'description' => __( 'Generates a form-tag for a <a href="https://contactform7.com/submit-button/">submit button</a>.', 'contact-form-7' ), |
| 59 | ), |
| 60 | ); |
| 61 | |
| 62 | $tgg = new WPCF7_TagGeneratorGenerator( $options['content'] ); |
| 63 | |
| 64 | $formatter = new WPCF7_HTMLFormatter(); |
| 65 | |
| 66 | $formatter->append_start_tag( 'header', array( |
| 67 | 'class' => 'description-box', |
| 68 | ) ); |
| 69 | |
| 70 | $formatter->append_start_tag( 'h3' ); |
| 71 | |
| 72 | $formatter->append_preformatted( |
| 73 | esc_html( $field_types['submit']['heading'] ) |
| 74 | ); |
| 75 | |
| 76 | $formatter->end_tag( 'h3' ); |
| 77 | |
| 78 | $formatter->append_start_tag( 'p' ); |
| 79 | |
| 80 | $formatter->append_preformatted( |
| 81 | wp_kses_data( $field_types['submit']['description'] ) |
| 82 | ); |
| 83 | |
| 84 | $formatter->end_tag( 'header' ); |
| 85 | |
| 86 | $formatter->append_start_tag( 'div', array( |
| 87 | 'class' => 'control-box', |
| 88 | ) ); |
| 89 | |
| 90 | $formatter->call_user_func( static function () use ( $tgg, $field_types ) { |
| 91 | $tgg->print( 'field_type', array( |
| 92 | 'select_options' => array( |
| 93 | 'submit' => $field_types['submit']['display_name'], |
| 94 | ), |
| 95 | ) ); |
| 96 | |
| 97 | $tgg->print( 'class_attr' ); |
| 98 | |
| 99 | $tgg->print( 'default_value', array( |
| 100 | 'title' => __( 'Label', 'contact-form-7' ), |
| 101 | ) ); |
| 102 | } ); |
| 103 | |
| 104 | $formatter->end_tag( 'div' ); |
| 105 | |
| 106 | $formatter->append_start_tag( 'footer', array( |
| 107 | 'class' => 'insert-box', |
| 108 | ) ); |
| 109 | |
| 110 | $formatter->call_user_func( static function () use ( $tgg, $field_types ) { |
| 111 | $tgg->print( 'insert_box_content' ); |
| 112 | } ); |
| 113 | |
| 114 | $formatter->print(); |
| 115 | } |
| 116 |