classes.php
16 years ago
formatting.php
16 years ago
functions.php
16 years ago
pipe.php
16 years ago
shortcodes.php
16 years ago
functions.php
173 lines
| 1 | <?php |
| 2 | |
| 3 | function wpcf7_default_message( $status ) { |
| 4 | switch ( $status ) { |
| 5 | case 'mail_sent_ok': |
| 6 | return __( 'Your message was sent successfully. Thanks.', 'wpcf7' ); |
| 7 | case 'mail_sent_ng': |
| 8 | return __( 'Failed to send your message. Please try later or contact administrator by other way.', 'wpcf7' ); |
| 9 | case 'akismet_says_spam': |
| 10 | return __( 'Failed to send your message. Please try later or contact administrator by other way.', 'wpcf7' ); |
| 11 | case 'validation_error': |
| 12 | return __( 'Validation errors occurred. Please confirm the fields and submit it again.', 'wpcf7' ); |
| 13 | case 'accept_terms': |
| 14 | return __( 'Please accept the terms to proceed.', 'wpcf7' ); |
| 15 | case 'invalid_email': |
| 16 | return __( 'Email address seems invalid.', 'wpcf7' ); |
| 17 | case 'invalid_required': |
| 18 | return __( 'Please fill the required field.', 'wpcf7' ); |
| 19 | case 'captcha_not_match': |
| 20 | return __( 'Your entered code is incorrect.', 'wpcf7' ); |
| 21 | case 'quiz_answer_not_correct': |
| 22 | return __( 'Your answer is not correct.', 'wpcf7' ); |
| 23 | case 'upload_failed': |
| 24 | return __( 'Failed to upload file.', 'wpcf7' ); |
| 25 | case 'upload_file_type_invalid': |
| 26 | return __( 'This file type is not allowed.', 'wpcf7' ); |
| 27 | case 'upload_file_too_large': |
| 28 | return __( 'This file is too large.', 'wpcf7' ); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | function wpcf7_default_form_template() { |
| 33 | $template .= '<p>' . __( 'Your Name', 'wpcf7' ) . ' ' . __( '(required)', 'wpcf7' ) . '<br />' . "\n"; |
| 34 | $template .= ' [text* your-name] </p>' . "\n\n"; |
| 35 | $template .= '<p>' . __( 'Your Email', 'wpcf7' ) . ' ' . __( '(required)', 'wpcf7' ) . '<br />' . "\n"; |
| 36 | $template .= ' [email* your-email] </p>' . "\n\n"; |
| 37 | $template .= '<p>' . __( 'Subject', 'wpcf7' ) . '<br />' . "\n"; |
| 38 | $template .= ' [text your-subject] </p>' . "\n\n"; |
| 39 | $template .= '<p>' . __( 'Your Message', 'wpcf7' ) . '<br />' . "\n"; |
| 40 | $template .= ' [textarea your-message] </p>' . "\n\n"; |
| 41 | $template .= '<p>[submit "' . __( 'Send', 'wpcf7' ) . '"]</p>'; |
| 42 | return $template; |
| 43 | } |
| 44 | |
| 45 | function wpcf7_default_mail_template() { |
| 46 | $subject = '[your-subject]'; |
| 47 | $sender = '[your-name] <[your-email]>'; |
| 48 | $body = '[your-message]'; |
| 49 | $recipient = get_option( 'admin_email' ); |
| 50 | return compact( 'subject', 'sender', 'body', 'recipient' ); |
| 51 | } |
| 52 | |
| 53 | function wpcf7_default_mail_2_template() { |
| 54 | $active = false; |
| 55 | $subject = '[your-subject]'; |
| 56 | $sender = '[your-name] <[your-email]>'; |
| 57 | $body = '[your-message]'; |
| 58 | $recipient = '[your-email]'; |
| 59 | return compact( 'active', 'subject', 'sender', 'body', 'recipient' ); |
| 60 | } |
| 61 | |
| 62 | function wpcf7_default_messages_template() { |
| 63 | $mail_sent_ok = wpcf7_default_message( 'mail_sent_ok' ); |
| 64 | $mail_sent_ng = wpcf7_default_message( 'mail_sent_ng' ); |
| 65 | $akismet_says_spam = wpcf7_default_message( 'akismet_says_spam' ); |
| 66 | $validation_error = wpcf7_default_message( 'validation_error' ); |
| 67 | $accept_terms = wpcf7_default_message( 'accept_terms' ); |
| 68 | $invalid_email = wpcf7_default_message( 'invalid_email' ); |
| 69 | $invalid_required = wpcf7_default_message( 'invalid_required' ); |
| 70 | $quiz_answer_not_correct = wpcf7_default_message( 'quiz_answer_not_correct' ); |
| 71 | $captcha_not_match = wpcf7_default_message( 'captcha_not_match' ); |
| 72 | $upload_failed = wpcf7_default_message( 'upload_failed' ); |
| 73 | $upload_file_type_invalid = wpcf7_default_message( 'upload_file_type_invalid' ); |
| 74 | $upload_file_too_large = wpcf7_default_message( 'upload_file_too_large' ); |
| 75 | |
| 76 | return compact( 'mail_sent_ok', 'mail_sent_ng', 'akismet_says_spam', |
| 77 | 'validation_error', 'accept_terms', 'invalid_email', 'invalid_required', 'quiz_answer_not_correct', |
| 78 | 'captcha_not_match', 'upload_failed', 'upload_file_type_invalid', 'upload_file_too_large' ); |
| 79 | } |
| 80 | |
| 81 | function wpcf7_upload_dir( $type = false ) { |
| 82 | $siteurl = get_option( 'siteurl' ); |
| 83 | $upload_path = trim( get_option( 'upload_path' ) ); |
| 84 | if ( empty( $upload_path ) ) |
| 85 | $dir = WP_CONTENT_DIR . '/uploads'; |
| 86 | else |
| 87 | $dir = $upload_path; |
| 88 | |
| 89 | $dir = path_join( ABSPATH, $dir ); |
| 90 | |
| 91 | if ( ! $url = get_option( 'upload_url_path' ) ) { |
| 92 | if ( empty( $upload_path ) || $upload_path == $dir ) |
| 93 | $url = WP_CONTENT_URL . '/uploads'; |
| 94 | else |
| 95 | $url = trailingslashit( $siteurl ) . $upload_path; |
| 96 | } |
| 97 | |
| 98 | if ( defined( 'UPLOADS' ) ) { |
| 99 | $dir = ABSPATH . UPLOADS; |
| 100 | $url = trailingslashit( $siteurl ) . UPLOADS; |
| 101 | } |
| 102 | |
| 103 | if ( 'dir' == $type ) |
| 104 | return $dir; |
| 105 | if ( 'url' == $type ) |
| 106 | return $url; |
| 107 | return array( 'dir' => $dir, 'url' => $url ); |
| 108 | } |
| 109 | |
| 110 | function wpcf7_captcha_tmp_dir() { |
| 111 | if ( defined( 'WPCF7_CAPTCHA_TMP_DIR' ) ) |
| 112 | return WPCF7_CAPTCHA_TMP_DIR; |
| 113 | else |
| 114 | return wpcf7_upload_dir( 'dir' ) . '/wpcf7_captcha'; |
| 115 | } |
| 116 | |
| 117 | function wpcf7_captcha_tmp_url() { |
| 118 | if ( defined( 'WPCF7_CAPTCHA_TMP_URL' ) ) |
| 119 | return WPCF7_CAPTCHA_TMP_URL; |
| 120 | else |
| 121 | return wpcf7_upload_dir( 'url' ) . '/wpcf7_captcha'; |
| 122 | } |
| 123 | |
| 124 | function wpcf7_upload_tmp_dir() { |
| 125 | if ( defined( 'WPCF7_UPLOADS_TMP_DIR' ) ) |
| 126 | return WPCF7_UPLOADS_TMP_DIR; |
| 127 | else |
| 128 | return wpcf7_upload_dir( 'dir' ) . '/wpcf7_uploads'; |
| 129 | } |
| 130 | |
| 131 | function wpcf7_json( $items ) { |
| 132 | if ( is_array( $items ) ) { |
| 133 | if ( empty( $items ) ) |
| 134 | return 'null'; |
| 135 | |
| 136 | $keys = array_keys( $items ); |
| 137 | $all_int = true; |
| 138 | foreach ( $keys as $key ) { |
| 139 | if ( ! is_int( $key ) ) { |
| 140 | $all_int = false; |
| 141 | break; |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | if ( $all_int ) { |
| 146 | $children = array(); |
| 147 | foreach ( $items as $item ) { |
| 148 | $children[] = wpcf7_json( $item ); |
| 149 | } |
| 150 | return '[' . join( ', ', $children ) . ']'; |
| 151 | } else { // Object |
| 152 | $children = array(); |
| 153 | foreach ( $items as $key => $item ) { |
| 154 | $key = esc_js( (string) $key ); |
| 155 | if ( preg_match( '/[^a-zA-Z]/', $key ) ) |
| 156 | $key = '"' . $key . '"'; |
| 157 | |
| 158 | $children[] = $key . ': ' . wpcf7_json( $item ); |
| 159 | } |
| 160 | return '{ ' . join( ', ', $children ) . ' }'; |
| 161 | } |
| 162 | } elseif ( is_numeric( $items ) ) { |
| 163 | return (string) $items; |
| 164 | } elseif ( is_bool( $items ) ) { |
| 165 | return $items ? '1' : '0'; |
| 166 | } elseif ( is_null( $items ) ) { |
| 167 | return 'null'; |
| 168 | } else { |
| 169 | return '"' . esc_js( (string) $items ) . '"'; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | ?> |