css
11 years ago
images
11 years ago
includes
11 years ago
js
12 years ago
admin-functions.php
11 years ago
admin.php
11 years ago
edit-contact-form.php
11 years ago
admin-functions.php
164 lines
| 1 | <?php |
| 2 | |
| 3 | function wpcf7_current_action() { |
| 4 | if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) |
| 5 | return $_REQUEST['action']; |
| 6 | |
| 7 | if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) |
| 8 | return $_REQUEST['action2']; |
| 9 | |
| 10 | return false; |
| 11 | } |
| 12 | |
| 13 | function wpcf7_admin_has_edit_cap() { |
| 14 | return current_user_can( 'wpcf7_edit_contact_forms' ); |
| 15 | } |
| 16 | |
| 17 | function wpcf7_add_tag_generator( $name, $title, $elm_id, $callback, $options = array() ) { |
| 18 | global $wpcf7_tag_generators; |
| 19 | |
| 20 | $name = trim( $name ); |
| 21 | if ( '' == $name ) |
| 22 | return false; |
| 23 | |
| 24 | if ( ! is_array( $wpcf7_tag_generators ) ) |
| 25 | $wpcf7_tag_generators = array(); |
| 26 | |
| 27 | $wpcf7_tag_generators[$name] = array( |
| 28 | 'title' => $title, |
| 29 | 'content' => $elm_id, |
| 30 | 'options' => $options ); |
| 31 | |
| 32 | if ( is_callable( $callback ) ) |
| 33 | add_action( 'wpcf7_admin_footer', $callback ); |
| 34 | |
| 35 | return true; |
| 36 | } |
| 37 | |
| 38 | function wpcf7_tag_generators() { |
| 39 | global $wpcf7_tag_generators; |
| 40 | |
| 41 | $taggenerators = array(); |
| 42 | |
| 43 | foreach ( (array) $wpcf7_tag_generators as $name => $tg ) { |
| 44 | $taggenerators[$name] = array_merge( |
| 45 | (array) $tg['options'], |
| 46 | array( 'title' => $tg['title'], 'content' => $tg['content'] ) ); |
| 47 | } |
| 48 | |
| 49 | return $taggenerators; |
| 50 | } |
| 51 | |
| 52 | function wpcf7_save_contact_form( $post_id = -1 ) { |
| 53 | if ( -1 != $post_id ) { |
| 54 | $contact_form = wpcf7_contact_form( $post_id ); |
| 55 | } |
| 56 | |
| 57 | if ( empty( $contact_form ) ) { |
| 58 | $contact_form = WPCF7_ContactForm::get_template(); |
| 59 | } |
| 60 | |
| 61 | if ( isset( $_POST['wpcf7-title'] ) ) { |
| 62 | $contact_form->set_title( $_POST['wpcf7-title'] ); |
| 63 | } |
| 64 | |
| 65 | if ( isset( $_POST['wpcf7-locale'] ) ) { |
| 66 | $locale = trim( $_POST['wpcf7-locale'] ); |
| 67 | |
| 68 | if ( wpcf7_is_valid_locale( $locale ) ) { |
| 69 | $contact_form->locale = $locale; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | $properties = $contact_form->get_properties(); |
| 74 | |
| 75 | if ( isset( $_POST['wpcf7-form'] ) ) { |
| 76 | $properties['form'] = trim( $_POST['wpcf7-form'] ); |
| 77 | } |
| 78 | |
| 79 | $mail = $properties['mail']; |
| 80 | |
| 81 | if ( isset( $_POST['wpcf7-mail-subject'] ) ) { |
| 82 | $mail['subject'] = trim( $_POST['wpcf7-mail-subject'] ); |
| 83 | } |
| 84 | |
| 85 | if ( isset( $_POST['wpcf7-mail-sender'] ) ) { |
| 86 | $mail['sender'] = trim( $_POST['wpcf7-mail-sender'] ); |
| 87 | } |
| 88 | |
| 89 | if ( isset( $_POST['wpcf7-mail-body'] ) ) { |
| 90 | $mail['body'] = trim( $_POST['wpcf7-mail-body'] ); |
| 91 | } |
| 92 | |
| 93 | if ( isset( $_POST['wpcf7-mail-recipient'] ) ) { |
| 94 | $mail['recipient'] = trim( $_POST['wpcf7-mail-recipient'] ); |
| 95 | } |
| 96 | |
| 97 | if ( isset( $_POST['wpcf7-mail-additional-headers'] ) ) { |
| 98 | $mail['additional_headers'] = trim( $_POST['wpcf7-mail-additional-headers'] ); |
| 99 | } |
| 100 | |
| 101 | if ( isset( $_POST['wpcf7-mail-attachments'] ) ) { |
| 102 | $mail['attachments'] = trim( $_POST['wpcf7-mail-attachments'] ); |
| 103 | } |
| 104 | |
| 105 | $mail['use_html'] = ! empty( $_POST['wpcf7-mail-use-html'] ); |
| 106 | $mail['exclude_blank'] = ! empty( $_POST['wpcf7-mail-exclude-blank'] ); |
| 107 | |
| 108 | $properties['mail'] = $mail; |
| 109 | |
| 110 | $mail_2 = $properties['mail_2']; |
| 111 | |
| 112 | $mail_2['active'] = ! empty( $_POST['wpcf7-mail-2-active'] ); |
| 113 | |
| 114 | if ( isset( $_POST['wpcf7-mail-2-subject'] ) ) { |
| 115 | $mail_2['subject'] = trim( $_POST['wpcf7-mail-2-subject'] ); |
| 116 | } |
| 117 | |
| 118 | if ( isset( $_POST['wpcf7-mail-2-sender'] ) ) { |
| 119 | $mail_2['sender'] = trim( $_POST['wpcf7-mail-2-sender'] ); |
| 120 | } |
| 121 | |
| 122 | if ( isset( $_POST['wpcf7-mail-2-body'] ) ) { |
| 123 | $mail_2['body'] = trim( $_POST['wpcf7-mail-2-body'] ); |
| 124 | } |
| 125 | |
| 126 | if ( isset( $_POST['wpcf7-mail-2-recipient'] ) ) { |
| 127 | $mail_2['recipient'] = trim( $_POST['wpcf7-mail-2-recipient'] ); |
| 128 | } |
| 129 | |
| 130 | if ( isset( $_POST['wpcf7-mail-2-additional-headers'] ) ) { |
| 131 | $mail_2['additional_headers'] = trim( |
| 132 | $_POST['wpcf7-mail-2-additional-headers'] ); |
| 133 | } |
| 134 | |
| 135 | if ( isset( $_POST['wpcf7-mail-2-attachments'] ) ) { |
| 136 | $mail_2['attachments'] = trim( $_POST['wpcf7-mail-2-attachments'] ); |
| 137 | } |
| 138 | |
| 139 | $mail_2['use_html'] = ! empty( $_POST['wpcf7-mail-2-use-html'] ); |
| 140 | $mail_2['exclude_blank'] = ! empty( $_POST['wpcf7-mail-2-exclude-blank'] ); |
| 141 | |
| 142 | $properties['mail_2'] = $mail_2; |
| 143 | |
| 144 | foreach ( wpcf7_messages() as $key => $arr ) { |
| 145 | $field_name = 'wpcf7-message-' . strtr( $key, '_', '-' ); |
| 146 | |
| 147 | if ( isset( $_POST[$field_name] ) ) { |
| 148 | $properties['messages'][$key] = trim( $_POST[$field_name] ); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | if ( isset( $_POST['wpcf7-additional-settings'] ) ) { |
| 153 | $properties['additional_settings'] = trim( |
| 154 | $_POST['wpcf7-additional-settings'] ); |
| 155 | } |
| 156 | |
| 157 | $contact_form->set_properties( $properties ); |
| 158 | |
| 159 | do_action( 'wpcf7_save_contact_form', $contact_form ); |
| 160 | |
| 161 | return $contact_form->save(); |
| 162 | } |
| 163 | |
| 164 | ?> |