4eb93de4ca0ec88510d38b503ba6439b22bbaefe
[danixland-contact-form.git] / include / dnxcf_options-display.php
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
30 function dnxcf_settings_email_address_section_text() {
31 ?>
32 <p><?php _e( 'This is the email address where you will receive all email from the contact form.', 'dnxcf' ); ?></p>
33 <?php
34 }
35
36 function dnxcf_settings_subject_section_text() {
37 ?>
38 <p><?php _e( 'These are the options that you are giving as a dropdown list to your users.', 'dnxcf' ); ?></p>
39 <?php
40 }
41
42 function dnxcf_settings_mailfrom_section_text() {
43 ?>
44 <p>
45 <?php _e( 'Here you can set the sender email address for the contact form.', 'dnxcf' ); ?><br />
46 <?php
47 global $dnxcf_options;
48 $dnxcf_options = get_option( 'dnxcf_options' );
49 echo sprintf(
50 __( 'The emails you will receive will be from: <code>%1$s < %2$s ></code>', 'dnxcf' ),
51 $dnxcf_options['dnxcf_from_name'],
52 $dnxcf_options['dnxcf_from_email']
53 );
54 ?>
55 <br />
56 <?php _e( 'so just make sure you whitelist this address in your mail client to avoid losing important messages.', 'dnxcf' ); ?>
57 </p>
58 <?php
59 }
60
61 function dnxcf_settings_privacy_section_text() {
62 ?>
63 <p><?php _e( 'Enter here the content of your privacy policy relative to the contact form.', 'dnxcf' ); ?></p>
64 <?php
65 }
66
67 function dnxcf_settings_googlemap_section_text() {
68 ?>
69 <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>
70 <?php
71 }
72
73 // Content type for email sent via this form
74 function dnxcf_setting_content_type_display() {
75 $dnxcf_options = get_option( 'dnxcf_options' );
76 // 1 = text/plain
77 // 2 = text/html
78 ?>
79 <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 />
80 <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 />
81 <span class="description"><?php _e( 'Send plain (text) or rich (html) messages.', 'dnxcf' ); ?></span>
82 <?php
83 }
84
85 // Receiving email name
86 function dnxcf_setting_email_name_display() {
87 $dnxcf_options = get_option( 'dnxcf_options' );
88 ?>
89 <input type="text" name="dnxcf_options[dnxcf_recv_name]" value="<?php echo $dnxcf_options['dnxcf_recv_name']; ?>" /><br />
90 <span class="description"><?php _e( 'This is how you will be called in every email you will receive from this contact form.', 'dnxcf' ); ?></span>
91 <?php
92 }
93
94 // Receiving email address
95 function dnxcf_setting_email_address_display() {
96 $dnxcf_options = get_option( 'dnxcf_options' );
97 ?>
98 <input type="email" name="dnxcf_options[dnxcf_recv_email]" value="<?php echo $dnxcf_options['dnxcf_recv_email']; ?>" /><br />
99 <span class="description"><?php _e( 'If you leave this field empty the admin email address will be used.', 'dnxcf' ); ?></span>
100 <?php
101 }
102
103 // Custom subject options
104 function dnxcf_setting_subject_display() {
105 $dnxcf_options = get_option( 'dnxcf_options' );
106 ?>
107 <textarea name="dnxcf_options[dnxcf_subject]" rows="10" cols="80" /><?php echo implode( "\n", $dnxcf_options['dnxcf_subject'] ); ?></textarea><br />
108 <span class="description"><?php _e( 'Insert one option per line. If you leave this area empty the default options will be used.', 'dnxcf' ); ?></span>
109 <?php
110 }
111
112 // Sender email address
113 function dnxcf_setting_mailfrom_mail_display() {
114 $dnxcf_options = get_option( 'dnxcf_options' );
115 ?>
116 <input type="email" name="dnxcf_options[dnxcf_from_email]" value="<?php echo $dnxcf_options['dnxcf_from_email']; ?>" /><br />
117 <span class="description"><?php _e( 'This is the email address from which you will receive communications.', 'dnxcf' ); ?></span>
118 <?php
119 }
120
121 // Sender name
122 function dnxcf_setting_mailfrom_name_display() {
123 $dnxcf_options = get_option( 'dnxcf_options' );
124 ?>
125 <input type="text" name="dnxcf_options[dnxcf_from_name]" value="<?php echo $dnxcf_options['dnxcf_from_name']; ?>" /><br />
126 <span class="description"><?php _e( 'This is the name associated to the above email address.', 'dnxcf' ); ?></span>
127 <?php
128 }
129
130 // Privacy Policy
131 function dnxcf_setting_privacy_display() {
132 $dnxcf_options = get_option( 'dnxcf_options' );
133 ?>
134 <textarea name="dnxcf_options[dnxcf_privacy]" rows="10" cols="80" /><?php echo wptexturize( $dnxcf_options['dnxcf_privacy'] ); ?></textarea><br />
135 <span class="description"><?php _e( 'The text of the privacy policy, Leave empty to disable the policy area in the form.', 'dnxcf' ); ?></span>
136 <?php
137 }
138
139 // api key
140 function dnxcf_setting_googlemap_apikey_display() {
141 $dnxcf_options = get_option( 'dnxcf_options' );
142 $dev_links = 'https://developers.google.com/maps/documentation/javascript/get-api-key';
143 ?>
144 <input type="text" name="dnxcf_options[dnxcf_apikey]" value="<?php echo $dnxcf_options['dnxcf_apikey']; ?>" /><br />
145 <span class="description"><?php _e( 'You need an API Key from the developers console in order to use Google Maps', 'dnxcf' ); ?></span><br />
146 <span class="description"><?php echo sprintf( __( 'check the <a href="%s">documentation</a> on the google developers platform.', 'dnxcf' ), $dev_links ); ?></span><br />
147 <span class="description"><?php _e( 'Leave empty to disable the display of a Google Map on the form.', 'dnxcf' ); ?></span>
148 <?php
149 }
150
151 // map message
152 function dnxcf_setting_googlemap_message_display() {
153 $dnxcf_options = get_option( 'dnxcf_options' );
154 ?>
155 <input type="text" name="dnxcf_options[dnxcf_gmap_message]" value="<?php echo $dnxcf_options['dnxcf_gmap_message']; ?>" /><br />
156 <span class="description"><?php _e( 'Address to be displayed as a popup inside the map. Leave empty to disable.', 'dnxcf' ); ?></span>
157 <?php
158 }
159
160 // Longitude
161 function dnxcf_setting_googlemap_long_display() {
162 $dnxcf_options = get_option( 'dnxcf_options' );
163 ?>
164 <input type="number" name="dnxcf_options[dnxcf_longitude]" value="<?php echo $dnxcf_options['dnxcf_longitude']; ?>" step="0.000001" /><br />
165 <span class="description"><?php _e( 'Longitude value, eg. 16.290340', 'dnxcf' ); ?></span><br />
166 <span class="description"><?php _e( '+/- 180 degrees value accepted', 'dnxcf' ); ?></span>
167 <?php
168 }
169
170 // Latitude
171 function dnxcf_setting_googlemap_lat_display() {
172 $dnxcf_options = get_option( 'dnxcf_options' );
173 ?>
174 <input type="number" name="dnxcf_options[dnxcf_latitude]" value="<?php echo $dnxcf_options['dnxcf_latitude']; ?>" step="0.000001" /><br />
175 <span class="description"><?php _e( 'Latitude value, eg. 38.269625.', 'dnxcf' ); ?></span><br />
176 <span class="description"><?php _e( '+/- 90 degrees value accepted', 'dnxcf' ); ?></span>
177 <?php
178 }