b96bc758 |
1 | <?php |
2 | defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
3 | // usage: $id, $title, $callback, $page |
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'); |
9 | add_settings_section('dnxcf_googlemap', __('Google Map', 'dnxcf'), 'dnxcf_settings_googlemap_section_text', 'dnxcf_options_sections'); |
10 | |
11 | |
12 | // usage: $id, $title, $callback, $page, $section, $args |
13 | add_settings_field('dnxcf_setting_content_type_display', __('content type?', 'dnxcf'), 'dnxcf_setting_content_type_display', 'dnxcf_options_sections', 'dnxcf_content_type'); |
14 | add_settings_field('dnxcf_setting_email_name_display', __('name?', 'dnxcf'), 'dnxcf_setting_email_name_display', 'dnxcf_options_sections', 'dnxcf_email_address'); |
15 | add_settings_field('dnxcf_setting_email_address_display', __('email address?', 'dnxcf'), 'dnxcf_setting_email_address_display', 'dnxcf_options_sections', 'dnxcf_email_address'); |
16 | add_settings_field('dnxcf_setting_subject_display', __('subject options?', 'dnxcf'), 'dnxcf_setting_subject_display', 'dnxcf_options_sections', 'dnxcf_subject_options'); |
17 | add_settings_field('dnxcf_setting_mailfrom_name_display', __('name?', 'dnxcf'), 'dnxcf_setting_mailfrom_name_display', 'dnxcf_options_sections', 'dnxcf_mailfrom_options'); |
18 | add_settings_field('dnxcf_setting_mailfrom_mail_display', __('email address?', 'dnxcf'), 'dnxcf_setting_mailfrom_mail_display', 'dnxcf_options_sections', 'dnxcf_mailfrom_options'); |
19 | add_settings_field('dnxcf_setting_privacy_display', __('policy text?', 'dnxcf'), 'dnxcf_setting_privacy_display', 'dnxcf_options_sections', 'dnxcf_privacy_policy'); |
20 | add_settings_field('dnxcf_setting_googlemap_apikey', __('GMaps API Key?', 'dnxcf'), 'dnxcf_setting_googlemap_apikey_display', 'dnxcf_options_sections', 'dnxcf_googlemap'); |
21 | add_settings_field('dnxcf_setting_googlemap_latitude', __('Latitude?', 'dnxcf'), 'dnxcf_setting_googlemap_lat_display', 'dnxcf_options_sections', 'dnxcf_googlemap'); |
22 | add_settings_field('dnxcf_setting_googlemap_longitude', __('Longitude?', 'dnxcf'), 'dnxcf_setting_googlemap_long_display', 'dnxcf_options_sections', 'dnxcf_googlemap'); |
23 | add_settings_field('dnxcf_setting_googlemap_message', __('Address?', 'dnxcf'), 'dnxcf_setting_googlemap_message_display', 'dnxcf_options_sections', 'dnxcf_googlemap'); |
24 | |
25 | function dnxcf_settings_content_type_section_text() { ?> |
26 | <p><?php _e( 'Here you can change the content type of your emails, either html or plain text.', 'dnxcf' ); ?></p> |
27 | <?php } |
28 | |
29 | function dnxcf_settings_email_address_section_text() { ?> |
30 | <p><?php _e( 'This is the email address where you will receive all email from the contact form.', 'dnxcf' ); ?></p> |
31 | <?php } |
32 | |
33 | function dnxcf_settings_subject_section_text() { ?> |
34 | <p><?php _e( 'These are the options that you are giving as a dropdown list to your users.', 'dnxcf' ); ?></p> |
35 | <?php } |
36 | |
37 | function dnxcf_settings_mailfrom_section_text() { ?> |
38 | <p> |
39 | <?php _e( 'Here you can set the sender email address for the contact form.', 'dnxcf' ); ?><br /> |
40 | <?php |
41 | global $dnxcf_options; |
42 | $dnxcf_options = get_option( 'dnxcf_options' ); |
43 | echo sprintf( |
44 | __( 'The emails you will receive will be from: <code>%s < %s ></code>', 'dnxcf' ), |
45 | $dnxcf_options['dnxcf_from_name'], |
46 | $dnxcf_options['dnxcf_from_email'] |
47 | ); |
48 | ?><br /> |
49 | <?php _e( 'so just make sure you whitelist this address in your mail client to avoid losing important messages.', 'dnxcf' ); ?> |
50 | </p> |
51 | <?php } |
52 | |
53 | function dnxcf_settings_privacy_section_text() { ?> |
54 | <p><?php _e( 'Enter here the content of your privacy policy relative to the contact form.', 'dnxcf' ); ?></p> |
55 | <?php } |
56 | |
57 | function dnxcf_settings_googlemap_section_text() { ?> |
58 | <p><?php _e( 'Here you can change various settings for the map that will be displayed on the form page. <strong>Note:</strong> if the API Key value is missing the map will be disabled.', 'dnxcf' ); ?></p> |
59 | <?php } |
60 | |
61 | // Content type for email sent via this form |
62 | function dnxcf_setting_content_type_display() { |
63 | $dnxcf_options = get_option( 'dnxcf_options' ); |
64 | // 1 = text/plain |
65 | // 2 = text/html |
66 | ?> |
67 | <input type="radio" name="dnxcf_options[dnxcf_content_type]" <?php checked( $dnxcf_options['dnxcf_content_type'], '1' ); ?> value='1' /> <?php _e('text/plain', 'dnxcf'); ?><br /> |
68 | <input type="radio" name="dnxcf_options[dnxcf_content_type]" <?php checked( $dnxcf_options['dnxcf_content_type'], '2' ); ?> value='2' /> <?php _e('text/html', 'dnxcf'); ?><br /> |
69 | <span class="description"><?php _e('Send plain (text) or rich (html) messages.', 'dnxcf'); ?></span> |
70 | <?php } |
71 | |
72 | // Receiving email name |
73 | function dnxcf_setting_email_name_display() { |
74 | $dnxcf_options = get_option( 'dnxcf_options' ); ?> |
75 | <input type="text" name="dnxcf_options[dnxcf_recv_name]" value="<?php echo $dnxcf_options['dnxcf_recv_name']; ?>" /><br /> |
76 | <span class="description"><?php _e('This is how you will be called in every email you will receive from this contact form.', 'dnxcf'); ?></span> |
77 | <?php } |
78 | |
79 | // Receiving email address |
80 | function dnxcf_setting_email_address_display() { |
81 | $dnxcf_options = get_option( 'dnxcf_options' ); ?> |
82 | <input type="email" name="dnxcf_options[dnxcf_recv_email]" value="<?php echo $dnxcf_options['dnxcf_recv_email']; ?>" /><br /> |
83 | <span class="description"><?php _e('If you leave this field empty the admin email address will be used.', 'dnxcf'); ?></span> |
84 | <?php } |
85 | |
86 | // Custom subject options |
87 | function dnxcf_setting_subject_display() { |
88 | $dnxcf_options = get_option( 'dnxcf_options' ); ?> |
89 | <textarea name="dnxcf_options[dnxcf_subject]" rows="10" cols="80" /><?php echo implode("\n", $dnxcf_options['dnxcf_subject']); ?></textarea><br /> |
90 | <span class="description"><?php _e('Insert one option per line. If you leave this area empty the default options will be used.', 'dnxcf'); ?></span> |
91 | <?php } |
92 | |
93 | // Sender email address |
94 | function dnxcf_setting_mailfrom_mail_display() { |
95 | $dnxcf_options = get_option( 'dnxcf_options' ); ?> |
96 | <input type="email" name="dnxcf_options[dnxcf_from_email]" value="<?php echo $dnxcf_options['dnxcf_from_email']; ?>" /><br /> |
97 | <span class="description"><?php _e('This is the email address from which you will receive communications.', 'dnxcf'); ?></span> |
98 | <?php } |
99 | |
100 | // Sender name |
101 | function dnxcf_setting_mailfrom_name_display() { |
102 | $dnxcf_options = get_option( 'dnxcf_options' ); ?> |
103 | <input type="text" name="dnxcf_options[dnxcf_from_name]" value="<?php echo $dnxcf_options['dnxcf_from_name']; ?>" /><br /> |
104 | <span class="description"><?php _e('This is the name associated to the above email address.', 'dnxcf'); ?></span> |
105 | <?php } |
106 | |
107 | // Privacy Policy |
108 | function dnxcf_setting_privacy_display() { |
109 | $dnxcf_options = get_option( 'dnxcf_options' ); ?> |
110 | <textarea name="dnxcf_options[dnxcf_privacy]" rows="10" cols="80" /><?php echo wptexturize($dnxcf_options['dnxcf_privacy']); ?></textarea><br /> |
111 | <span class="description"><?php _e('The text of the privacy policy, Leave empty to disable the policy area in the form.', 'dnxcf'); ?></span> |
112 | <?php } |
113 | |
114 | // api key |
115 | function dnxcf_setting_googlemap_apikey_display() { |
116 | $dnxcf_options = get_option( 'dnxcf_options' ); |
117 | $dev_links = 'https://developers.google.com/maps/documentation/javascript/get-api-key'; ?> |
118 | <input type="text" name="dnxcf_options[dnxcf_apikey]" value="<?php echo $dnxcf_options['dnxcf_apikey']; ?>" /><br /> |
119 | <span class="description"><?php _e('You need an API Key from the developers console in order to use Google Maps', 'dnxcf'); ?></span><br /> |
120 | <span class="description"><?php echo sprintf(__('check the <a href="%s">documentation</a> on the google developers platform.', 'dnxcf'), $dev_links ); ?></span><br /> |
121 | <span class="description"><?php _e('Leave empty to disable the display of a Google Map on the form.', 'dnxcf'); ?></span> |
122 | <?php } |
123 | |
124 | // map message |
125 | function dnxcf_setting_googlemap_message_display() { |
126 | $dnxcf_options = get_option( 'dnxcf_options' ); ?> |
127 | <input type="text" name="dnxcf_options[dnxcf_gmap_message]" value="<?php echo $dnxcf_options['dnxcf_gmap_message']; ?>" /><br /> |
128 | <span class="description"><?php _e('Address to be displayed as a popup inside the map. Leave empty to disable.', 'dnxcf'); ?></span> |
129 | <?php } |
130 | |
131 | // Longitude |
132 | function dnxcf_setting_googlemap_long_display() { |
133 | $dnxcf_options = get_option( 'dnxcf_options' ); ?> |
134 | <input type="number" name="dnxcf_options[dnxcf_longitude]" value="<?php echo $dnxcf_options['dnxcf_longitude']; ?>" step="0.000001" /><br /> |
135 | <span class="description"><?php _e('Longitude value, eg. 16.290340', 'dnxcf'); ?></span><br /> |
136 | <span class="description"><?php _e('+/- 180 degrees value accepted', 'dnxcf'); ?></span> |
137 | <?php } |
138 | |
139 | // Latitude |
140 | function dnxcf_setting_googlemap_lat_display() { |
141 | $dnxcf_options = get_option( 'dnxcf_options' ); ?> |
142 | <input type="number" name="dnxcf_options[dnxcf_latitude]" value="<?php echo $dnxcf_options['dnxcf_latitude']; ?>" step="0.000001" /><br /> |
143 | <span class="description"><?php _e('Latitude value, eg. 38.269625.', 'dnxcf'); ?></span><br /> |
144 | <span class="description"><?php _e('+/- 90 degrees value accepted', 'dnxcf'); ?></span> |
145 | <?php } |