b96bc758 |
1 | <?php |
244ec72c |
2 | defined( 'ABSPATH' ) || die( 'No script kiddies please!' ); |
3 | // usage: $id, $title, $callback, $page |
8c3e9b00 |
4 | add_settings_section( 'dnxcf_mailfrom_options', __( 'Sender email address', 'dnxcf' ), 'dnxcf_settings_mailfrom_section_text', 'dnxcf_options_sections' ); |
5 | add_settings_section( 'dnxcf_email_address', __( 'Recipient email address', 'dnxcf' ), 'dnxcf_settings_email_address_section_text', 'dnxcf_options_sections' ); |
6 | add_settings_section( 'dnxcf_content_type', __( 'Content type', 'dnxcf' ), 'dnxcf_settings_content_type_section_text', 'dnxcf_options_sections' ); |
7 | add_settings_section( 'dnxcf_subject_options', __( 'Subject', 'dnxcf' ), 'dnxcf_settings_subject_section_text', 'dnxcf_options_sections' ); |
8 | add_settings_section( 'dnxcf_privacy_policy', __( 'Privacy policy', 'dnxcf' ), 'dnxcf_settings_privacy_section_text', 'dnxcf_options_sections' ); |
8c3e9b00 |
9 | |
10 | // usage: $id, $title, $callback, $page, $section, $args |
11 | add_settings_field( 'dnxcf_setting_content_type_display', __( 'content type?', 'dnxcf' ), 'dnxcf_setting_content_type_display', 'dnxcf_options_sections', 'dnxcf_content_type' ); |
12 | add_settings_field( 'dnxcf_setting_email_name_display', __( 'name?', 'dnxcf' ), 'dnxcf_setting_email_name_display', 'dnxcf_options_sections', 'dnxcf_email_address' ); |
13 | add_settings_field( 'dnxcf_setting_email_address_display', __( 'email address?', 'dnxcf' ), 'dnxcf_setting_email_address_display', 'dnxcf_options_sections', 'dnxcf_email_address' ); |
14 | add_settings_field( 'dnxcf_setting_subject_display', __( 'subject options?', 'dnxcf' ), 'dnxcf_setting_subject_display', 'dnxcf_options_sections', 'dnxcf_subject_options' ); |
15 | add_settings_field( 'dnxcf_setting_mailfrom_name_display', __( 'name?', 'dnxcf' ), 'dnxcf_setting_mailfrom_name_display', 'dnxcf_options_sections', 'dnxcf_mailfrom_options' ); |
16 | add_settings_field( 'dnxcf_setting_mailfrom_mail_display', __( 'email address?', 'dnxcf' ), 'dnxcf_setting_mailfrom_mail_display', 'dnxcf_options_sections', 'dnxcf_mailfrom_options' ); |
17 | add_settings_field( 'dnxcf_setting_privacy_display', __( 'policy text?', 'dnxcf' ), 'dnxcf_setting_privacy_display', 'dnxcf_options_sections', 'dnxcf_privacy_policy' ); |
b96bc758 |
18 | |
19 | function dnxcf_settings_content_type_section_text() { ?> |
244ec72c |
20 | <p><?php esc_html_e( 'Here you can change the content type of your emails, either html or plain text.', 'dnxcf' ); ?></p> |
8c3e9b00 |
21 | <?php |
22 | } |
b96bc758 |
23 | |
8c3e9b00 |
24 | function dnxcf_settings_email_address_section_text() { |
25 | ?> |
244ec72c |
26 | <p><?php esc_html_e( 'This is the email address where you will receive all email from the contact form.', 'dnxcf' ); ?></p> |
8c3e9b00 |
27 | <?php |
28 | } |
b96bc758 |
29 | |
8c3e9b00 |
30 | function dnxcf_settings_subject_section_text() { |
31 | ?> |
244ec72c |
32 | <p><?php esc_html_e( 'These are the options that you are giving as a dropdown list to your users.', 'dnxcf' ); ?></p> |
8c3e9b00 |
33 | <?php |
34 | } |
b96bc758 |
35 | |
8c3e9b00 |
36 | function dnxcf_settings_mailfrom_section_text() { |
37 | ?> |
b96bc758 |
38 | <p> |
244ec72c |
39 | <?php esc_html_e( 'Here you can set the sender email address for the contact form.', 'dnxcf' ); ?><br /> |
8c3e9b00 |
40 | <?php |
41 | global $dnxcf_options; |
42 | $dnxcf_options = get_option( 'dnxcf_options' ); |
244ec72c |
43 | // translators: %1$s = from name inside email; $2$s = from email address |
8c3e9b00 |
44 | echo sprintf( |
45 | __( 'The emails you will receive will be from: <code>%1$s < %2$s ></code>', 'dnxcf' ), |
46 | $dnxcf_options['dnxcf_from_name'], |
47 | $dnxcf_options['dnxcf_from_email'] |
48 | ); |
49 | ?> |
50 | <br /> |
244ec72c |
51 | <?php esc_html_e( 'so just make sure you whitelist this address in your mail client to avoid losing important messages.', 'dnxcf' ); ?> |
b96bc758 |
52 | </p> |
8c3e9b00 |
53 | <?php |
54 | } |
b96bc758 |
55 | |
8c3e9b00 |
56 | function dnxcf_settings_privacy_section_text() { |
57 | ?> |
244ec72c |
58 | <p><?php esc_html_e( 'Enter here the content of your privacy policy relative to the contact form.', 'dnxcf' ); ?></p> |
8c3e9b00 |
59 | <?php |
60 | } |
b96bc758 |
61 | |
62 | // Content type for email sent via this form |
63 | function dnxcf_setting_content_type_display() { |
8c3e9b00 |
64 | $dnxcf_options = get_option( 'dnxcf_options' ); |
65 | // 1 = text/plain |
66 | // 2 = text/html |
67 | ?> |
244ec72c |
68 | <input type="radio" name="dnxcf_options[dnxcf_content_type]" <?php checked( $dnxcf_options['dnxcf_content_type'], '1' ); ?> value='1' /> <?php esc_html_e( 'text/plain', 'dnxcf' ); ?><br /> |
69 | <input type="radio" name="dnxcf_options[dnxcf_content_type]" <?php checked( $dnxcf_options['dnxcf_content_type'], '2' ); ?> value='2' /> <?php esc_html_e( 'text/html', 'dnxcf' ); ?><br /> |
70 | <span class="description"><?php esc_html_e( 'Send plain (text) or rich (html) messages.', 'dnxcf' ); ?></span> |
8c3e9b00 |
71 | <?php |
72 | } |
b96bc758 |
73 | |
74 | // Receiving email name |
75 | function dnxcf_setting_email_name_display() { |
8c3e9b00 |
76 | $dnxcf_options = get_option( 'dnxcf_options' ); |
77 | ?> |
b96bc758 |
78 | <input type="text" name="dnxcf_options[dnxcf_recv_name]" value="<?php echo $dnxcf_options['dnxcf_recv_name']; ?>" /><br /> |
244ec72c |
79 | <span class="description"><?php esc_html_e( 'This is how you will be called in every email you will receive from this contact form.', 'dnxcf' ); ?></span> |
8c3e9b00 |
80 | <?php |
81 | } |
b96bc758 |
82 | |
83 | // Receiving email address |
84 | function dnxcf_setting_email_address_display() { |
8c3e9b00 |
85 | $dnxcf_options = get_option( 'dnxcf_options' ); |
86 | ?> |
b96bc758 |
87 | <input type="email" name="dnxcf_options[dnxcf_recv_email]" value="<?php echo $dnxcf_options['dnxcf_recv_email']; ?>" /><br /> |
244ec72c |
88 | <span class="description"><?php esc_html_e( 'If you leave this field empty the admin email address will be used.', 'dnxcf' ); ?></span> |
8c3e9b00 |
89 | <?php |
90 | } |
b96bc758 |
91 | |
92 | // Custom subject options |
93 | function dnxcf_setting_subject_display() { |
8c3e9b00 |
94 | $dnxcf_options = get_option( 'dnxcf_options' ); |
95 | ?> |
96 | <textarea name="dnxcf_options[dnxcf_subject]" rows="10" cols="80" /><?php echo implode( "\n", $dnxcf_options['dnxcf_subject'] ); ?></textarea><br /> |
244ec72c |
97 | <span class="description"><?php esc_html_e( 'Insert one option per line. If you leave this area empty the default options will be used.', 'dnxcf' ); ?></span> |
8c3e9b00 |
98 | <?php |
99 | } |
b96bc758 |
100 | |
101 | // Sender email address |
102 | function dnxcf_setting_mailfrom_mail_display() { |
8c3e9b00 |
103 | $dnxcf_options = get_option( 'dnxcf_options' ); |
104 | ?> |
b96bc758 |
105 | <input type="email" name="dnxcf_options[dnxcf_from_email]" value="<?php echo $dnxcf_options['dnxcf_from_email']; ?>" /><br /> |
244ec72c |
106 | <span class="description"><?php esc_html_e( 'This is the email address from which you will receive communications.', 'dnxcf' ); ?></span> |
8c3e9b00 |
107 | <?php |
108 | } |
b96bc758 |
109 | |
110 | // Sender name |
111 | function dnxcf_setting_mailfrom_name_display() { |
8c3e9b00 |
112 | $dnxcf_options = get_option( 'dnxcf_options' ); |
113 | ?> |
b96bc758 |
114 | <input type="text" name="dnxcf_options[dnxcf_from_name]" value="<?php echo $dnxcf_options['dnxcf_from_name']; ?>" /><br /> |
244ec72c |
115 | <span class="description"><?php esc_html_e( 'This is the name associated to the above email address.', 'dnxcf' ); ?></span> |
8c3e9b00 |
116 | <?php |
117 | } |
b96bc758 |
118 | |
119 | // Privacy Policy |
120 | function dnxcf_setting_privacy_display() { |
8c3e9b00 |
121 | $dnxcf_options = get_option( 'dnxcf_options' ); |
122 | ?> |
123 | <textarea name="dnxcf_options[dnxcf_privacy]" rows="10" cols="80" /><?php echo wptexturize( $dnxcf_options['dnxcf_privacy'] ); ?></textarea><br /> |
244ec72c |
124 | <span class="description"><?php esc_html_e( 'The text of the privacy policy, Leave empty to disable the policy area in the form.', 'dnxcf' ); ?></span> |
8c3e9b00 |
125 | <?php |
126 | } |