<?php
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
-/*
+/*
Plugin Name: danixland contact form
Description: A simple yet powerful contact form plugin
Plugin URI: https://danix.xyz/?p=3577
* Add plugin i18n domain: dnxcf
* @since 0.2
*/
-load_plugin_textdomain('dnxcf', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/');
+load_plugin_textdomain( 'dnxcf', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
/**
* Let's load our helper file ( DB initialization and stuff )
register_activation_hook( __FILE__, 'dnxcf_set_db_version' );
register_activation_hook( __FILE__, 'dnxcf_db_check' );
-if ( is_admin()) {
- require_once( dirname(__FILE__) . '/include/dnxcf_settings.php' );
+if ( is_admin() ) {
+ require_once( dirname( __FILE__ ) . '/include/dnxcf_settings.php' );
}
// Add Genericons, used in the contact form.
function dnxcf_scripts() {
- wp_enqueue_style( 'dnxcf_genericons', plugins_url( '/style/genericons/genericons.css', __FILE__ ), array(), '3.4.1' );
- wp_enqueue_style( 'dnxcf_helper_style', plugins_url( '/style/dnxcf_style.css', __FILE__ ), array(), '4.4.2' );
+ wp_enqueue_style( 'dnxcf_genericons', plugins_url( '/style/genericons/genericons.css', __FILE__ ), array(), '3.4.1' );
+ wp_enqueue_style( 'dnxcf_helper_style', plugins_url( '/style/dnxcf_style.css', __FILE__ ), array(), '4.4.2' );
}
add_action( 'wp_enqueue_scripts', 'dnxcf_scripts' );
* @since 1.0
*/
function dnxcf_gmap_enqueue() {
- global $dnxcf_options;
- $dnxcf_options = get_option('dnxcf_options');
- $latitude = $dnxcf_options['dnxcf_latitude'];
- $longitude = $dnxcf_options['dnxcf_longitude'];
- $apikey = $dnxcf_options['dnxcf_apikey'];
- $sitename = get_bloginfo('name');
- $siteurl = get_bloginfo('url');
- $sitemsg = $dnxcf_options['dnxcf_gmap_message'];
- $visitus = __('Come visit us', 'dnxcf');
+ global $dnxcf_options;
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ $latitude = $dnxcf_options['dnxcf_latitude'];
+ $longitude = $dnxcf_options['dnxcf_longitude'];
+ $apikey = $dnxcf_options['dnxcf_apikey'];
+ $sitename = get_bloginfo( 'name' );
+ $siteurl = get_bloginfo( 'url' );
+ $sitemsg = $dnxcf_options['dnxcf_gmap_message'];
+ $visitus = __( 'Come visit us', 'dnxcf' );
-$popup_content = <<< DNX6655788EOT
+ $popup_content = <<< DNX6655788EOT
<div id="content">
<div id="siteNotice">
</div>
</div>
</div>
DNX6655788EOT;
-?>
+ ?>
<script>
- function initMap() {
- var location = {lat: <?php echo $latitude; ?>, lng: <?php echo $longitude; ?> };
- var map = new google.maps.Map( document.getElementById('dnxcf_gmap'), {zoom: 15, center: location} );
+ function initMap() {
+ var location = {lat: <?php echo $latitude; ?>, lng: <?php echo $longitude; ?> };
+ var map = new google.maps.Map( document.getElementById('dnxcf_gmap'), {zoom: 15, center: location} );
- contentString = <?php echo json_encode($popup_content); ?>;
- var infowindow = new google.maps.InfoWindow( {content: contentString} );
+ contentString = <?php echo json_encode( $popup_content ); ?>;
+ var infowindow = new google.maps.InfoWindow( {content: contentString} );
- var marker = new google.maps.Marker( {position: location, map: map, animation: google.maps.Animation.DROP} );
- marker.addListener('click', function() { infowindow.open(map, marker); });
- }
+ var marker = new google.maps.Marker( {position: location, map: map, animation: google.maps.Animation.DROP} );
+ marker.addListener('click', function() { infowindow.open(map, marker); });
+ }
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=<?php echo $apikey; ?>&callback=initMap" async defer></script>
-<?php }
+ <?php
+}
global $dnxcf_options;
-$dnxcf_options = get_option('dnxcf_options');
-if ( ! empty($dnxcf_options['dnxcf_apikey']) ) {
- add_action('wp_footer', 'dnxcf_gmap_enqueue');
+$dnxcf_options = get_option( 'dnxcf_options' );
+if ( ! empty( $dnxcf_options['dnxcf_apikey'] ) ) {
+ add_action( 'wp_footer', 'dnxcf_gmap_enqueue' );
}
* The actual contact form displayed using a shortcode
* @since 0.1
*/
-add_shortcode( 'dnx_contactform', 'dnxcf_return_form');
+add_shortcode( 'dnx_contactform', 'dnxcf_return_form' );
/*
* we use output buffer so that the form will stay at the bottom of content
- * allowing the user to write some text in the body of the page before
+ * allowing the user to write some text in the body of the page before
* displaying the form with the shortcode
* @since 0.5
*/
function dnxcf_return_form() {
- ob_start();
- dnxcf_display_form();
- $output = ob_get_contents();
- ob_end_clean();
- return $output;
+ ob_start();
+ dnxcf_display_form();
+ $output = ob_get_contents();
+ ob_end_clean();
+ return $output;
}
/*
* @since 0.2
*/
function dnxcf_display_form() {
- global $dnxcf_form_version, $dnxcf_options;
- $dnxcf_options = get_option('dnxcf_options');
+ global $dnxcf_form_version, $dnxcf_options;
+ $dnxcf_options = get_option( 'dnxcf_options' );
- $dnxcf_pid = md5($dnxcf_options['dnxcf_pid_key']);
- $dnxcf_vers_id = md5($dnxcf_form_version);
- $dnxcf_date_id = md5(date('TOZ'));
- $dnxcf_eml_id = md5($dnxcf_options['dnxcf_recv_email']);
- $dnxcf_form_id = $dnxcf_pid . $dnxcf_vers_id . $dnxcf_eml_id . $dnxcf_date_id;
- $dnxcf_form_id = strtoupper(md5($dnxcf_form_id));
- $dnxcf_form_id = 'ID' . $dnxcf_form_id . 'DNX';
- $dnxcf_send_value = trim( strtolower( 'submit_' . md5($dnxcf_form_id) ) );
+ $dnxcf_pid = md5( $dnxcf_options['dnxcf_pid_key'] );
+ $dnxcf_vers_id = md5( $dnxcf_form_version );
+ $dnxcf_date_id = md5( date( 'TOZ' ) );
+ $dnxcf_eml_id = md5( $dnxcf_options['dnxcf_recv_email'] );
+ $dnxcf_form_id = $dnxcf_pid . $dnxcf_vers_id . $dnxcf_eml_id . $dnxcf_date_id;
+ $dnxcf_form_id = strtoupper( md5( $dnxcf_form_id ) );
+ $dnxcf_form_id = 'ID' . $dnxcf_form_id . 'DNX';
+ $dnxcf_send_value = trim( strtolower( 'submit_' . md5( $dnxcf_form_id ) ) );
- if ( isset( $_POST[$dnxcf_send_value] ) ) { // the form has been submitted
- $dnxcf_email_output = ( '1' == $dnxcf_options['dnxcf_content_type'] ) ? 'text/plain' : 'text/html';
- $dnxcf_form_name = 'dnxcf_form_' . $dnxcf_pid;
- $dnxcf_form_action = 'dnxcf_submit_' . $dnxcf_form_id;
- // valid html used to validate the comment content.
- $valid_html = array(
- 'a' => array(
- 'href' => array(),
- 'title' => array()
- ),
- 'br' => array(),
- 'em' => array(),
- 'strong' => array(),
- 'p' => array(),
- 'pre' => array(),
- 'code' => array()
- );
- // security checks before submitting the form
- if ( $_SERVER['REQUEST_URI'] == $_POST['_wp_http_referer'] && wp_verify_nonce( $_POST[ $dnxcf_form_name], $dnxcf_form_action ) ) {
+ if ( isset( $_POST[ $dnxcf_send_value ] ) ) { // the form has been submitted
+ $dnxcf_email_output = ( '1' == $dnxcf_options['dnxcf_content_type'] ) ? 'text/plain' : 'text/html';
+ $dnxcf_form_name = 'dnxcf_form_' . $dnxcf_pid;
+ $dnxcf_form_action = 'dnxcf_submit_' . $dnxcf_form_id;
+ // valid html used to validate the comment content.
+ $valid_html = array(
+ 'a' => array(
+ 'href' => array(),
+ 'title' => array(),
+ ),
+ 'br' => array(),
+ 'em' => array(),
+ 'strong' => array(),
+ 'p' => array(),
+ 'pre' => array(),
+ 'code' => array(),
+ );
+ // security checks before submitting the form
+ if ( $_SERVER['REQUEST_URI'] == $_POST['_wp_http_referer'] && wp_verify_nonce( $_POST[ $dnxcf_form_name ], $dnxcf_form_action ) ) {
- $dnxcf_posted = array();
- // let's gather some data about the user submitting the form
- $dnxcf_ltd = trim(strip_tags(stripslashes(current_time("mysql"))));
- $dnxcf_hst = trim(strip_tags(stripslashes(getenv("REMOTE_ADDR"))));
- $dnxcf_ua = trim(strip_tags(stripslashes($_SERVER['HTTP_USER_AGENT'])));
- // our posted options, arranged in one nice array
- $dnxcf_posted['dnxcf_name'] = sanitize_text_field($_POST['dnxcf_name']);
- $dnxcf_posted['dnxcf_email'] = sanitize_email($_POST['dnxcf_email']);
- $dnxcf_posted['dnxcf_website'] = esc_url($_POST['dnxcf_website']);
- $dnxcf_posted['dnxcf_subject'] = sanitize_text_field($_POST['dnxcf_subject']);
- $dnxcf_posted['dnxcf_message'] = wp_kses($_POST['dnxcf_message'], $valid_html);
- // let's begin with our email data, like receiver email, subject ecc.
- $dnxcf_to = $dnxcf_options['dnxcf_recv_email'];
- $dnxcf_headers = "Reply-To: " . $dnxcf_posted['dnxcf_email'];
- $dnxcf_subject = __('Contact from "', 'dnxcf') . get_bloginfo('name') . '" - ' . $dnxcf_posted['dnxcf_subject'];
+ $dnxcf_posted = array();
+ // let's gather some data about the user submitting the form
+ $dnxcf_ltd = trim( strip_tags( stripslashes( current_time( 'mysql' ) ) ) );
+ $dnxcf_hst = trim( strip_tags( stripslashes( getenv( 'REMOTE_ADDR' ) ) ) );
+ $dnxcf_ua = trim( strip_tags( stripslashes( $_SERVER['HTTP_USER_AGENT'] ) ) );
+ // our posted options, arranged in one nice array
+ $dnxcf_posted['dnxcf_name'] = sanitize_text_field( $_POST['dnxcf_name'] );
+ $dnxcf_posted['dnxcf_email'] = sanitize_email( $_POST['dnxcf_email'] );
+ $dnxcf_posted['dnxcf_website'] = esc_url( $_POST['dnxcf_website'] );
+ $dnxcf_posted['dnxcf_subject'] = sanitize_text_field( $_POST['dnxcf_subject'] );
+ $dnxcf_posted['dnxcf_message'] = wp_kses( $_POST['dnxcf_message'], $valid_html );
+ // let's begin with our email data, like receiver email, subject ecc.
+ $dnxcf_to = $dnxcf_options['dnxcf_recv_email'];
+ $dnxcf_headers = 'Reply-To: ' . $dnxcf_posted['dnxcf_email'];
+ $dnxcf_subject = __( 'Contact from "', 'dnxcf' ) . get_bloginfo( 'name' ) . '" - ' . $dnxcf_posted['dnxcf_subject'];
- // check for our content type and arrange our info accordingly
- if ( 'text/html' == $dnxcf_email_output ) {
- require( apply_filters( 'dnxcf_template_file', dirname( __FILE__ ) . '/include/dnxcf_mail_template_danixland.php') );
- $dnxcf_email_data = array(
- 'ownname' => $dnxcf_options['dnxcf_recv_name'],
- 'site' => get_bloginfo('name'),
- 'time' => $dnxcf_ltd,
- 'host' => $dnxcf_hst,
- 'ua' => $dnxcf_ua,
- );
- $dnxcf_message = dnxcf_email_content( $dnxcf_email_data, $dnxcf_posted );
- } else { // content_type is set to text/plain
- $dnxcf_message = sprintf(
- __("Hello \"%s\",\nyou are being contacted by %s on %s.\n%s has provided the following informations:\n\tEmail:\t\t%s\n\tWebsite:\t%s\n\tMessage:\n\n%s", 'dnxcf'),
- $dnxcf_options['dnxcf_recv_name'],
- $dnxcf_posted['dnxcf_name'],
- get_bloginfo('name'),
- $dnxcf_posted['dnxcf_name'],
- $dnxcf_posted['dnxcf_email'],
- $dnxcf_posted['dnxcf_website'],
- $dnxcf_posted['dnxcf_message']
- );
- $dnxcf_message .= "\n\n##-----------#-----------#-----------##\n\n";
- $dnxcf_message .= sprintf(
- __("We have also collected the following informations:\n\tBrowser:\t%s\n\tTime:\t\t%s\n\tIP Address:\t%s\n", 'dnxcf'),
- $dnxcf_ua,
- $dnxcf_ltd,
- $dnxcf_hst
- );
- } // end check for mail_content_type
- $dnxcf_mailed = wp_mail( $dnxcf_to, $dnxcf_subject, $dnxcf_message, $dnxcf_headers );
- if ( $dnxcf_mailed ) { ?>
- <p id="dnxcf_success"><?php _e('your email was sent successfully. Here\'s the data you submitted via our form.', 'dnxcf' ); ?></p>
- <p>
- <dl>
- <dt><?php _e('Your Name:', 'dnxcf'); ?></dt>
- <dd><?php echo $dnxcf_posted['dnxcf_name']; ?></dd>
- <dt><?php _e('Your e-mail:', 'dnxcf'); ?></dt>
- <dd><?php echo $dnxcf_posted['dnxcf_email']; ?></dd>
- <dt><?php _e('Subject of your message:', 'dnxcf'); ?></dt>
- <dd><?php echo $dnxcf_posted['dnxcf_subject']; ?></dd>
- <dt><?php _e('Text of your Message:', 'dnxcf'); ?></dt>
- <dd><blockquote><?php echo wptexturize( wpautop( $dnxcf_posted['dnxcf_message'] ) ); ?></blockquote></dd>
- </dl>
- </p>
- <p><?php _e('we also collected some data for tecnical reasons.', 'dnxcf'); ?></p>
- <p>
- <dl>
- <dt><?php _e('Your IP address:', 'dnxcf'); ?></dt>
- <dd><?php echo $dnxcf_hst; ?></dd>
- <dt><?php _e('Your Browser:', 'dnxcf'); ?></dt>
- <dd><?php echo $dnxcf_ua; ?></dd>
- </dl>
- </p>
- <?php } else { ?>
- <p id="dnxcf_result_failure"><?php printf( __('there was a problem processing your email. Please contact the <a href="mailto:%s">administrator</a>.', 'dnxcf'), get_bloginfo('admin_email') ); ?></p>
- <?php } ?>
-
-<?php
- } else { // Houston we have a problem, spammer detected
- // we might want to use the data we have and send a mail to the admin just in case...
-?>
- <p id="dnxcf_spammer"><?php _e('looks like you don\'t belong here. We don\'t like spammers. Go away now!', 'dnxcf'); ?></p>
-<?php
- } // end check for wp_nonce
+ // check for our content type and arrange our info accordingly
+ if ( 'text/html' == $dnxcf_email_output ) {
+ require( apply_filters( 'dnxcf_template_file', dirname( __FILE__ ) . '/include/dnxcf_mail_template_danixland.php' ) );
+ $dnxcf_email_data = array(
+ 'ownname' => $dnxcf_options['dnxcf_recv_name'],
+ 'site' => get_bloginfo( 'name' ),
+ 'time' => $dnxcf_ltd,
+ 'host' => $dnxcf_hst,
+ 'ua' => $dnxcf_ua,
+ );
+ $dnxcf_message = dnxcf_email_content( $dnxcf_email_data, $dnxcf_posted );
+ } else { // content_type is set to text/plain
+ $dnxcf_message = sprintf(
+ __( "Hello \"%1\$s\",\nyou are being contacted by %2\$s on %3\$s.\n%4\$s has provided the following informations:\n\tEmail:\t\t%5\$s\n\tWebsite:\t%6\$s\n\tMessage:\n\n%7\$s", 'dnxcf' ),
+ $dnxcf_options['dnxcf_recv_name'],
+ $dnxcf_posted['dnxcf_name'],
+ get_bloginfo( 'name' ),
+ $dnxcf_posted['dnxcf_name'],
+ $dnxcf_posted['dnxcf_email'],
+ $dnxcf_posted['dnxcf_website'],
+ $dnxcf_posted['dnxcf_message']
+ );
+ $dnxcf_message .= "\n\n##-----------#-----------#-----------##\n\n";
+ $dnxcf_message .= sprintf(
+ __( "We have also collected the following informations:\n\tBrowser:\t%1\$s\n\tTime:\t\t%2\$s\n\tIP Address:\t%3\$s\n", 'dnxcf' ),
+ $dnxcf_ua,
+ $dnxcf_ltd,
+ $dnxcf_hst
+ );
+ } // end check for mail_content_type
+ $dnxcf_mailed = wp_mail( $dnxcf_to, $dnxcf_subject, $dnxcf_message, $dnxcf_headers );
+ if ( $dnxcf_mailed ) {
+ ?>
+ <p id="dnxcf_success"><?php _e( 'your email was sent successfully. Here\'s the data you submitted via our form.', 'dnxcf' ); ?></p>
+ <p>
+ <dl>
+ <dt><?php _e( 'Your Name:', 'dnxcf' ); ?></dt>
+ <dd><?php echo $dnxcf_posted['dnxcf_name']; ?></dd>
+ <dt><?php _e( 'Your e-mail:', 'dnxcf' ); ?></dt>
+ <dd><?php echo $dnxcf_posted['dnxcf_email']; ?></dd>
+ <dt><?php _e( 'Subject of your message:', 'dnxcf' ); ?></dt>
+ <dd><?php echo $dnxcf_posted['dnxcf_subject']; ?></dd>
+ <dt><?php _e( 'Text of your Message:', 'dnxcf' ); ?></dt>
+ <dd><blockquote><?php echo wptexturize( wpautop( $dnxcf_posted['dnxcf_message'] ) ); ?></blockquote></dd>
+ </dl>
+ </p>
+ <p><?php _e( 'we also collected some data for tecnical reasons.', 'dnxcf' ); ?></p>
+ <p>
+ <dl>
+ <dt><?php _e( 'Your IP address:', 'dnxcf' ); ?></dt>
+ <dd><?php echo $dnxcf_hst; ?></dd>
+ <dt><?php _e( 'Your Browser:', 'dnxcf' ); ?></dt>
+ <dd><?php echo $dnxcf_ua; ?></dd>
+ </dl>
+ </p>
+ <?php } else { ?>
+ <p id="dnxcf_result_failure"><?php printf( __( 'there was a problem processing your email. Please contact the <a href="mailto:%s">administrator</a>.', 'dnxcf' ), get_bloginfo( 'admin_email' ) ); ?></p>
+ <?php } ?>
- } else { // the post hasn't been submitted. Let's show the form
- global $dnxcf_options;
- $dnxcf_options = get_option('dnxcf_options');
-?>
- <!-- begin #dnxcf_form -->
- <form id="dnxcf_form" method="post" action="<?php echo htmlentities( $_SERVER['REQUEST_URI'] ); ?>">
- <?php wp_nonce_field( 'dnxcf_submit_' . $dnxcf_form_id, 'dnxcf_form_' . $dnxcf_pid, true, true );
- if ( ! empty($dnxcf_options['dnxcf_apikey']) ) : ?>
- <h4><?php _e('Our location', 'dnxcf'); ?></h4>
- <div id="dnxcf_gmap"></div>
- <?php endif; ?>
- <p class="comment-notes"><?php _e('Required fields are marked ', 'dnxcf'); ?><span class="required">*</span></p>
- <fieldset id="dnxcf_formwrap">
- <?php if ( $dnxcf_options['dnxcf_privacy'] ) : ?>
- <fieldset id="dnxcf_privacy">
- <h4><?php _e('Privacy:', 'dnxcf'); ?></h4>
- <div class="policy"><?php echo wpautop( wptexturize( $dnxcf_options['dnxcf_privacy'] ) ); ?></div>
- </fieldset>
- <?php endif; ?>
- <fieldset id="dnxcf_personal">
- <h4><?php _e('Personal Informations:', 'dnxcf'); ?></h4>
- <p class="dnxcf-name">
- <label class="genericon genericon-user" for="name"><span class="screen-reader-text"><?php _e('Full Name', 'dnxcf'); ?></span><span class="required">*</span></label>
- <input name="dnxcf_name" id="name" size="35" maxlength="40" type="text" placeholder="<?php _e('name', 'dnxcf'); ?>" required autocomplete="name">
- </p>
- <p class="dnxcf-email">
- <label class="genericon genericon-mail" for="email"><span class="screen-reader-text"><?php _e('email address', 'dnxcf'); ?></span><span class="required">*</span></label>
- <input name="dnxcf_email" id="email" size="35" maxlength="50" type="email" placeholder="<?php _e('e-mail', 'dnxcf'); ?>" required autocomplete="email">
- </p>
- <p class="dnxcf-website">
- <label for="website" class="genericon genericon-website"><span class="screen-reader-text"><?php _e('website', 'dnxcf'); ?></span></label>
- <input name="dnxcf_website" id="website" size="35" maxlength="50" type="url" placeholder="<?php _e('website', 'dnxcf'); ?>" autocomplete="url">
- </p>
- </fieldset>
- <fieldset id="dnxcf_message">
- <h4><?php _e('your message:', 'dnxcf'); ?></h4>
- <p class="dnxcf-subject">
- <label class="genericon genericon-tag" for="subject"><span class="screen-reader-text"><?php _e('subject', 'dnxcf'); ?></span><span class="required">*</span></label>
- <select name="dnxcf_subject" id="subject" required>
- <?php global $dnxcf_options;
- $dnxcf_options = get_option('dnxcf_options');
- $subject_options = $dnxcf_options['dnxcf_subject'];
- foreach ($subject_options as $option) {
- echo '<option value="' . $option . '">' . $option . '</option>';
- } ?>
- </select>
- </p>
- <p class="dnxcf-message">
- <label class="genericon genericon-comment" for="message"><span class="screen-reader-text"><?php _e('message', 'dnxcf'); ?></span><span class="required">*</span></label>
- <textarea name="dnxcf_message" id="message" cols="60" rows="12" placeholder="<?php _e('Comment Here', 'dnxcf'); ?>" required></textarea>
- </p>
- </fieldset>
- <fieldset id="dnxcf_send">
- <input type="submit" name="<?php echo $dnxcf_send_value; ?>" id="<?php echo $dnxcf_send_value; ?>" value="<?php _e('send message', 'dnxcf'); ?>">
- </fieldset>
- </fieldset><!-- #formwrap -->
- </form>
- <!-- end #dnxcf_form -->
-<?php
+ <?php
+ } else { // Houston we have a problem, spammer detected
+ // we might want to use the data we have and send a mail to the admin just in case...
+ ?>
+ <p id="dnxcf_spammer"><?php _e( 'looks like you don\'t belong here. We don\'t like spammers. Go away now!', 'dnxcf' ); ?></p>
+ <?php
+ } // end check for wp_nonce
+ } else { // the post hasn't been submitted. Let's show the form
+ global $dnxcf_options;
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
+ <!-- begin #dnxcf_form -->
+ <form id="dnxcf_form" method="post" action="<?php echo htmlentities( $_SERVER['REQUEST_URI'] ); ?>">
+ <?php
+ wp_nonce_field( 'dnxcf_submit_' . $dnxcf_form_id, 'dnxcf_form_' . $dnxcf_pid, true, true );
+ if ( ! empty( $dnxcf_options['dnxcf_apikey'] ) ) :
+ ?>
+ <h4><?php _e( 'Our location', 'dnxcf' ); ?></h4>
+ <div id="dnxcf_gmap"></div>
+ <?php endif; ?>
+ <p class="comment-notes"><?php _e( 'Required fields are marked ', 'dnxcf' ); ?><span class="required">*</span></p>
+ <fieldset id="dnxcf_formwrap">
+ <?php if ( $dnxcf_options['dnxcf_privacy'] ) : ?>
+ <fieldset id="dnxcf_privacy">
+ <h4><?php _e( 'Privacy:', 'dnxcf' ); ?></h4>
+ <div class="policy"><?php echo wpautop( wptexturize( $dnxcf_options['dnxcf_privacy'] ) ); ?></div>
+ </fieldset>
+ <?php endif; ?>
+ <fieldset id="dnxcf_personal">
+ <h4><?php _e( 'Personal Informations:', 'dnxcf' ); ?></h4>
+ <p class="dnxcf-name">
+ <label class="genericon genericon-user" for="name"><span class="screen-reader-text"><?php _e( 'Full Name', 'dnxcf' ); ?></span><span class="required">*</span></label>
+ <input name="dnxcf_name" id="name" size="35" maxlength="40" type="text" placeholder="<?php _e( 'name', 'dnxcf' ); ?>" required autocomplete="name">
+ </p>
+ <p class="dnxcf-email">
+ <label class="genericon genericon-mail" for="email"><span class="screen-reader-text"><?php _e( 'email address', 'dnxcf' ); ?></span><span class="required">*</span></label>
+ <input name="dnxcf_email" id="email" size="35" maxlength="50" type="email" placeholder="<?php _e( 'e-mail', 'dnxcf' ); ?>" required autocomplete="email">
+ </p>
+ <p class="dnxcf-website">
+ <label for="website" class="genericon genericon-website"><span class="screen-reader-text"><?php _e( 'website', 'dnxcf' ); ?></span></label>
+ <input name="dnxcf_website" id="website" size="35" maxlength="50" type="url" placeholder="<?php _e( 'website', 'dnxcf' ); ?>" autocomplete="url">
+ </p>
+ </fieldset>
+ <fieldset id="dnxcf_message">
+ <h4><?php _e( 'your message:', 'dnxcf' ); ?></h4>
+ <p class="dnxcf-subject">
+ <label class="genericon genericon-tag" for="subject"><span class="screen-reader-text"><?php _e( 'subject', 'dnxcf' ); ?></span><span class="required">*</span></label>
+ <select name="dnxcf_subject" id="subject" required>
+ <?php
+ global $dnxcf_options;
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ $subject_options = $dnxcf_options['dnxcf_subject'];
+ foreach ( $subject_options as $option ) {
+ echo '<option value="' . $option . '">' . $option . '</option>';
+ }
+ ?>
+ </select>
+ </p>
+ <p class="dnxcf-message">
+ <label class="genericon genericon-comment" for="message"><span class="screen-reader-text"><?php _e( 'message', 'dnxcf' ); ?></span><span class="required">*</span></label>
+ <textarea name="dnxcf_message" id="message" cols="60" rows="12" placeholder="<?php _e( 'Comment Here', 'dnxcf' ); ?>" required></textarea>
+ </p>
+ </fieldset>
+ <fieldset id="dnxcf_send">
+ <input type="submit" name="<?php echo $dnxcf_send_value; ?>" id="<?php echo $dnxcf_send_value; ?>" value="<?php _e( 'send message', 'dnxcf' ); ?>">
+ </fieldset>
+ </fieldset><!-- #formwrap -->
+ </form>
+ <!-- end #dnxcf_form -->
+ <?php
- } // end check for post submission
+ } // end check for post submission
} // end dnxcf_display_form()
-?>
\ No newline at end of file
+?>
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
// generate a unique code, allows for lenght parameter
-if ( ! function_exists('dnxcf_get_unique_code') ) {
+if ( ! function_exists( 'dnxcf_get_unique_code' ) ) {
- function dnxcf_get_unique_code( $length = "" ) {
- $code = md5( uniqid( rand(), true ) );
-
- if ($length != "") {
- return substr($code, 0, $length);
- } else {
- return $code;
- }
- }
+ function dnxcf_get_unique_code( $length = '' ) {
+ $code = md5( uniqid( rand(), true ) );
+ if ( $length != '' ) {
+ return substr( $code, 0, $length );
+ } else {
+ return $code;
+ }
+ }
}
// add button in edit pages to help include our form
function dnxcf_show_form_button() {
- $currentScreen = get_current_screen();
- if ( $currentScreen->parent_base == "edit" ) {
- echo '<button type="button" id="dnxcf-contact-form" class="button" onclick="dnxcf_send_code()"><span class="dashicons dashicons-testimonial"></span> ' . __('Add Contact Form', 'dnxcf' ) . '</button>';
- }
+ $currentScreen = get_current_screen();
+ if ( $currentScreen->parent_base == 'edit' ) {
+ echo '<button type="button" id="dnxcf-contact-form" class="button" onclick="dnxcf_send_code()"><span class="dashicons dashicons-testimonial"></span> ' . __( 'Add Contact Form', 'dnxcf' ) . '</button>';
+ }
}
add_action( 'media_buttons', 'dnxcf_show_form_button', 11 );
// the actual function that outputs our shortcode once the button is pressed
function dnxcf_insert_shortcode() {
- $currentScreen = get_current_screen();
- if ( $currentScreen->parent_base != "edit" ) {
- return;
- } ?>
+ $currentScreen = get_current_screen();
+ if ( $currentScreen->parent_base != 'edit' ) {
+ return;
+ } ?>
<script>
- function dnxcf_send_code() {
- //Send the shortcode to the editor
- window.send_to_editor("[dnx_contactform]");
- }
+ function dnxcf_send_code() {
+ //Send the shortcode to the editor
+ window.send_to_editor("[dnx_contactform]");
+ }
</script>
-<?php
+ <?php
}
add_action( 'admin_footer', 'dnxcf_insert_shortcode' );
// set default options for the plugin
function dnxcf_set_options() {
- $defaults = array(
- 'dnxcf_pid_key' => dnxcf_get_unique_code(12),
- 'dnxcf_recv_name' => 'admin',
- 'dnxcf_recv_email' => get_bloginfo('admin_email'),
- 'dnxcf_from_email' => 'info@some.url',
- 'dnxcf_from_name' => 'webmaster',
- 'dnxcf_subject' => array(
- __('I want to make a comment.', 'dnxcf'),
- __('I want to ask a question.', 'dnxcf'),
- __('I am interested in a product.', 'dnxcf'),
- __('I have to report a problem.', 'dnxcf'),
- __('Other (explain below)', 'dnxcf')
- ),
- // 1 = text/plain
- // 2 = text/html
- 'dnxcf_content_type' => '1',
- 'dnxcf_privacy' => '',
- 'dnxcf_latitude' => '38.2704',
- 'dnxcf_longitude' => '16.2971',
- 'dnxcf_apikey' => '',
- 'dnxcf_gmap_message' => '',
- 'dnxcf_DB_VERSION' => '2'
- );
- return $defaults;
+ $defaults = array(
+ 'dnxcf_pid_key' => dnxcf_get_unique_code( 12 ),
+ 'dnxcf_recv_name' => 'admin',
+ 'dnxcf_recv_email' => get_bloginfo( 'admin_email' ),
+ 'dnxcf_from_email' => 'info@some.url',
+ 'dnxcf_from_name' => 'webmaster',
+ 'dnxcf_subject' => array(
+ __( 'I want to make a comment.', 'dnxcf' ),
+ __( 'I want to ask a question.', 'dnxcf' ),
+ __( 'I am interested in a product.', 'dnxcf' ),
+ __( 'I have to report a problem.', 'dnxcf' ),
+ __( 'Other (explain below)', 'dnxcf' ),
+ ),
+ // 1 = text/plain
+ // 2 = text/html
+ 'dnxcf_content_type' => '1',
+ 'dnxcf_privacy' => '',
+ 'dnxcf_latitude' => '38.2704',
+ 'dnxcf_longitude' => '16.2971',
+ 'dnxcf_apikey' => '',
+ 'dnxcf_gmap_message' => '',
+ 'dnxcf_DB_VERSION' => '2',
+ );
+ return $defaults;
}
// helper function that starts up the DB
function dnxcf_db_init() {
- global $dnxcf_options;
- $dnxcf_options = get_option('dnxcf_options');
- if( false === $dnxcf_options ) {
- $dnxcf_options = dnxcf_set_options();
- }
- update_option('dnxcf_options', $dnxcf_options);
+ global $dnxcf_options;
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ if ( false === $dnxcf_options ) {
+ $dnxcf_options = dnxcf_set_options();
+ }
+ update_option( 'dnxcf_options', $dnxcf_options );
}
// helper function that performs a DB version update when needed
-function dnxcf_db_update($db_version) {
- global $dnxcf_options;
- $db_defaults = dnxcf_set_options();
- $merge = wp_parse_args( $dnxcf_options, $db_defaults );
- // update DB version
- $merge['dnxcf_DB_VERSION'] = $db_version;
- update_option('dnxcf_options', $merge);
+function dnxcf_db_update( $db_version ) {
+ global $dnxcf_options;
+ $db_defaults = dnxcf_set_options();
+ $merge = wp_parse_args( $dnxcf_options, $db_defaults );
+ // update DB version
+ $merge['dnxcf_DB_VERSION'] = $db_version;
+ update_option( 'dnxcf_options', $merge );
}
// helper function that performs a DB check and then an init/update action
function dnxcf_db_check() {
- global $dnxcf_options;
- if(false === $dnxcf_options) {
- dnxcf_db_init();
- }
- $old_db_version = $dnxcf_options['dnxcf_DB_VERSION'];
- $new_db_version = DNXCF_CURRENT_DB_VERSION;
- if(empty($old_db_version)) {
- dnxcf_db_init();
- }
- if( intval($old_db_version) < intval($new_db_version) ) {
- dnxcf_db_update( $new_db_version );
- }
+ global $dnxcf_options;
+ if ( false === $dnxcf_options ) {
+ dnxcf_db_init();
+ }
+ $old_db_version = $dnxcf_options['dnxcf_DB_VERSION'];
+ $new_db_version = DNXCF_CURRENT_DB_VERSION;
+ if ( empty( $old_db_version ) ) {
+ dnxcf_db_init();
+ }
+ if ( intval( $old_db_version ) < intval( $new_db_version ) ) {
+ dnxcf_db_update( $new_db_version );
+ }
}
// helper function that sets the current DB Version for comparison
function dnxcf_set_db_version() {
- // Define plugin database version. This should only change when new settings are added.
- if ( ! defined( 'DNXCF_CURRENT_DB_VERSION' ) ) {
- define( 'DNXCF_CURRENT_DB_VERSION', 4 );
- }
+ // Define plugin database version. This should only change when new settings are added.
+ if ( ! defined( 'DNXCF_CURRENT_DB_VERSION' ) ) {
+ define( 'DNXCF_CURRENT_DB_VERSION', 4 );
+ }
}
// set the "from" email name to a custom option specified by the user
function dnxcf_update_from_name() {
- global $dnxcf_options;
- $dnxcf_options = get_option('dnxcf_options');
- $dnxcf_defaults = dnxcf_set_options();
- $from_name = $dnxcf_options['dnxcf_from_name'];
- $orig_name = 'WordPress';
-
- $name = ( $orig_name != $from_name ) ? $from_name : false;
- return $name;
+ global $dnxcf_options;
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ $dnxcf_defaults = dnxcf_set_options();
+ $from_name = $dnxcf_options['dnxcf_from_name'];
+ $orig_name = 'WordPress';
+
+ $name = ( $orig_name != $from_name ) ? $from_name : false;
+ return $name;
+}
+if ( dnxcf_update_from_name() ) {
+ add_filter( 'wp_mail_from_name', 'dnxcf_update_from_name' );
}
-if (dnxcf_update_from_name())
- add_filter( 'wp_mail_from_name', 'dnxcf_update_from_name' );
// set the "from" email address to a custom option specified by the user
function dnxcf_update_from_email() {
- global $dnxcf_options;
- $dnxcf_options = get_option('dnxcf_options');
- $dnxcf_defaults = dnxcf_set_options();
- $from_mail = $dnxcf_options['dnxcf_from_email'];
- $orig_mail = $dnxcf_defaults['dnxcf_from_email'];
-
- $mail = ( $orig_mail != $from_mail ) ? $from_mail : false;
- return $mail;
+ global $dnxcf_options;
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ $dnxcf_defaults = dnxcf_set_options();
+ $from_mail = $dnxcf_options['dnxcf_from_email'];
+ $orig_mail = $dnxcf_defaults['dnxcf_from_email'];
+
+ $mail = ( $orig_mail != $from_mail ) ? $from_mail : false;
+ return $mail;
+}
+if ( dnxcf_update_from_email() ) {
+ add_filter( 'wp_mail_from', 'dnxcf_update_from_email' );
}
-if (dnxcf_update_from_email())
- add_filter( 'wp_mail_from', 'dnxcf_update_from_email' );
function dnxcf_update_content_type() {
- global $dnxcf_options;
- $dnxcf_options = get_option('dnxcf_options');
+ global $dnxcf_options;
+ $dnxcf_options = get_option( 'dnxcf_options' );
- // 1 = text/plain
- // 2 = text/html
- $content_type = ( "1" == $dnxcf_options['dnxcf_content_type'] ) ? 'text/plain' : 'text/html';
+ // 1 = text/plain
+ // 2 = text/html
+ $content_type = ( '1' == $dnxcf_options['dnxcf_content_type'] ) ? 'text/plain' : 'text/html';
- return $content_type;
+ return $content_type;
}
add_filter( 'wp_mail_content_type', 'dnxcf_update_content_type' );
-<?php
+<?php
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/**
* danixland-contact-form standard Template
// this is data gathered via various php variables and WordPress functions
$data = array(
- 'ownname' = '', // name of the person receiving the message aka US!
- 'site' = get_bloginfo('name'), // the site name
- 'time' = '', // string generated by current_time()
- 'host' = '', // string generated by getenv("REMOTE_ADDR")
- 'ua' = '' // string corresponding to $_SERVER['HTTP_USER_AGENT']
+ 'ownname' = '', // name of the person receiving the message aka US!
+ 'site' = get_bloginfo('name'), // the site name
+ 'time' = '', // string generated by current_time()
+ 'host' = '', // string generated by getenv("REMOTE_ADDR")
+ 'ua' = '' // string corresponding to $_SERVER['HTTP_USER_AGENT']
);
// this is data sent via $_POST by the form itself
$posted = array(
- 'dnxcf_name' = '', // the name of the user sending the message
- 'dnxcf_email' = '', // the user's email
- 'dnxcf_website' = '', // the user's website
- 'dnxcf_subject' = '', // the subject of the message
- 'dnxcf_message' = '' // the message body
+ 'dnxcf_name' = '', // the name of the user sending the message
+ 'dnxcf_email' = '', // the user's email
+ 'dnxcf_website' = '', // the user's website
+ 'dnxcf_subject' = '', // the subject of the message
+ 'dnxcf_message' = '' // the message body
);
*/
// always the same name or the main plugin won't be able to send emails
// NOTE TO SELF: "I need to fix this ASAP"
function dnxcf_email_content( $data = array(), $posted = array() ) {
- extract($data);
- extract($posted);
+ extract( $data );
+ extract( $posted );
- $ownurl = get_bloginfo('url');
-// heredoc to return the email content
- $output = <<<DNX44665312EOT
+ $ownurl = get_bloginfo( 'url' );
+ // heredoc to return the email content
+ $output = <<<DNX44665312EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
DNX44665312EOT;
- return $output;
+ return $output;
}
-?>
<?php
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
// usage: $id, $title, $callback, $page
-add_settings_section('dnxcf_mailfrom_options', __('Sender email address', 'dnxcf'), 'dnxcf_settings_mailfrom_section_text', 'dnxcf_options_sections');
-add_settings_section('dnxcf_email_address', __('Recipient email address', 'dnxcf'), 'dnxcf_settings_email_address_section_text', 'dnxcf_options_sections');
-add_settings_section('dnxcf_content_type', __('Content type', 'dnxcf'), 'dnxcf_settings_content_type_section_text', 'dnxcf_options_sections');
-add_settings_section('dnxcf_subject_options', __('Subject', 'dnxcf'), 'dnxcf_settings_subject_section_text', 'dnxcf_options_sections');
-add_settings_section('dnxcf_privacy_policy', __('Privacy policy', 'dnxcf'), 'dnxcf_settings_privacy_section_text', 'dnxcf_options_sections');
-add_settings_section('dnxcf_googlemap', __('Google Map', 'dnxcf'), 'dnxcf_settings_googlemap_section_text', 'dnxcf_options_sections');
-
-
-// usage: $id, $title, $callback, $page, $section, $args
-add_settings_field('dnxcf_setting_content_type_display', __('content type?', 'dnxcf'), 'dnxcf_setting_content_type_display', 'dnxcf_options_sections', 'dnxcf_content_type');
-add_settings_field('dnxcf_setting_email_name_display', __('name?', 'dnxcf'), 'dnxcf_setting_email_name_display', 'dnxcf_options_sections', 'dnxcf_email_address');
-add_settings_field('dnxcf_setting_email_address_display', __('email address?', 'dnxcf'), 'dnxcf_setting_email_address_display', 'dnxcf_options_sections', 'dnxcf_email_address');
-add_settings_field('dnxcf_setting_subject_display', __('subject options?', 'dnxcf'), 'dnxcf_setting_subject_display', 'dnxcf_options_sections', 'dnxcf_subject_options');
-add_settings_field('dnxcf_setting_mailfrom_name_display', __('name?', 'dnxcf'), 'dnxcf_setting_mailfrom_name_display', 'dnxcf_options_sections', 'dnxcf_mailfrom_options');
-add_settings_field('dnxcf_setting_mailfrom_mail_display', __('email address?', 'dnxcf'), 'dnxcf_setting_mailfrom_mail_display', 'dnxcf_options_sections', 'dnxcf_mailfrom_options');
-add_settings_field('dnxcf_setting_privacy_display', __('policy text?', 'dnxcf'), 'dnxcf_setting_privacy_display', 'dnxcf_options_sections', 'dnxcf_privacy_policy');
-add_settings_field('dnxcf_setting_googlemap_apikey', __('GMaps API Key?', 'dnxcf'), 'dnxcf_setting_googlemap_apikey_display', 'dnxcf_options_sections', 'dnxcf_googlemap');
-add_settings_field('dnxcf_setting_googlemap_latitude', __('Latitude?', 'dnxcf'), 'dnxcf_setting_googlemap_lat_display', 'dnxcf_options_sections', 'dnxcf_googlemap');
-add_settings_field('dnxcf_setting_googlemap_longitude', __('Longitude?', 'dnxcf'), 'dnxcf_setting_googlemap_long_display', 'dnxcf_options_sections', 'dnxcf_googlemap');
-add_settings_field('dnxcf_setting_googlemap_message', __('Address?', 'dnxcf'), 'dnxcf_setting_googlemap_message_display', 'dnxcf_options_sections', 'dnxcf_googlemap');
+add_settings_section( 'dnxcf_mailfrom_options', __( 'Sender email address', 'dnxcf' ), 'dnxcf_settings_mailfrom_section_text', 'dnxcf_options_sections' );
+add_settings_section( 'dnxcf_email_address', __( 'Recipient email address', 'dnxcf' ), 'dnxcf_settings_email_address_section_text', 'dnxcf_options_sections' );
+add_settings_section( 'dnxcf_content_type', __( 'Content type', 'dnxcf' ), 'dnxcf_settings_content_type_section_text', 'dnxcf_options_sections' );
+add_settings_section( 'dnxcf_subject_options', __( 'Subject', 'dnxcf' ), 'dnxcf_settings_subject_section_text', 'dnxcf_options_sections' );
+add_settings_section( 'dnxcf_privacy_policy', __( 'Privacy policy', 'dnxcf' ), 'dnxcf_settings_privacy_section_text', 'dnxcf_options_sections' );
+add_settings_section( 'dnxcf_googlemap', __( 'Google Map', 'dnxcf' ), 'dnxcf_settings_googlemap_section_text', 'dnxcf_options_sections' );
+
+
+// usage: $id, $title, $callback, $page, $section, $args
+add_settings_field( 'dnxcf_setting_content_type_display', __( 'content type?', 'dnxcf' ), 'dnxcf_setting_content_type_display', 'dnxcf_options_sections', 'dnxcf_content_type' );
+add_settings_field( 'dnxcf_setting_email_name_display', __( 'name?', 'dnxcf' ), 'dnxcf_setting_email_name_display', 'dnxcf_options_sections', 'dnxcf_email_address' );
+add_settings_field( 'dnxcf_setting_email_address_display', __( 'email address?', 'dnxcf' ), 'dnxcf_setting_email_address_display', 'dnxcf_options_sections', 'dnxcf_email_address' );
+add_settings_field( 'dnxcf_setting_subject_display', __( 'subject options?', 'dnxcf' ), 'dnxcf_setting_subject_display', 'dnxcf_options_sections', 'dnxcf_subject_options' );
+add_settings_field( 'dnxcf_setting_mailfrom_name_display', __( 'name?', 'dnxcf' ), 'dnxcf_setting_mailfrom_name_display', 'dnxcf_options_sections', 'dnxcf_mailfrom_options' );
+add_settings_field( 'dnxcf_setting_mailfrom_mail_display', __( 'email address?', 'dnxcf' ), 'dnxcf_setting_mailfrom_mail_display', 'dnxcf_options_sections', 'dnxcf_mailfrom_options' );
+add_settings_field( 'dnxcf_setting_privacy_display', __( 'policy text?', 'dnxcf' ), 'dnxcf_setting_privacy_display', 'dnxcf_options_sections', 'dnxcf_privacy_policy' );
+add_settings_field( 'dnxcf_setting_googlemap_apikey', __( 'GMaps API Key?', 'dnxcf' ), 'dnxcf_setting_googlemap_apikey_display', 'dnxcf_options_sections', 'dnxcf_googlemap' );
+add_settings_field( 'dnxcf_setting_googlemap_latitude', __( 'Latitude?', 'dnxcf' ), 'dnxcf_setting_googlemap_lat_display', 'dnxcf_options_sections', 'dnxcf_googlemap' );
+add_settings_field( 'dnxcf_setting_googlemap_longitude', __( 'Longitude?', 'dnxcf' ), 'dnxcf_setting_googlemap_long_display', 'dnxcf_options_sections', 'dnxcf_googlemap' );
+add_settings_field( 'dnxcf_setting_googlemap_message', __( 'Address?', 'dnxcf' ), 'dnxcf_setting_googlemap_message_display', 'dnxcf_options_sections', 'dnxcf_googlemap' );
function dnxcf_settings_content_type_section_text() { ?>
<p><?php _e( 'Here you can change the content type of your emails, either html or plain text.', 'dnxcf' ); ?></p>
-<?php }
+ <?php
+}
-function dnxcf_settings_email_address_section_text() { ?>
+function dnxcf_settings_email_address_section_text() {
+ ?>
<p><?php _e( 'This is the email address where you will receive all email from the contact form.', 'dnxcf' ); ?></p>
-<?php }
+ <?php
+}
-function dnxcf_settings_subject_section_text() { ?>
+function dnxcf_settings_subject_section_text() {
+ ?>
<p><?php _e( 'These are the options that you are giving as a dropdown list to your users.', 'dnxcf' ); ?></p>
-<?php }
+ <?php
+}
-function dnxcf_settings_mailfrom_section_text() { ?>
+function dnxcf_settings_mailfrom_section_text() {
+ ?>
<p>
-<?php _e( 'Here you can set the sender email address for the contact form.', 'dnxcf' ); ?><br />
-<?php
- global $dnxcf_options;
- $dnxcf_options = get_option( 'dnxcf_options' );
- echo sprintf(
- __( 'The emails you will receive will be from: <code>%s < %s ></code>', 'dnxcf' ),
- $dnxcf_options['dnxcf_from_name'],
- $dnxcf_options['dnxcf_from_email']
- );
-?><br />
-<?php _e( 'so just make sure you whitelist this address in your mail client to avoid losing important messages.', 'dnxcf' ); ?>
+ <?php _e( 'Here you can set the sender email address for the contact form.', 'dnxcf' ); ?><br />
+ <?php
+ global $dnxcf_options;
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ echo sprintf(
+ __( 'The emails you will receive will be from: <code>%1$s < %2$s ></code>', 'dnxcf' ),
+ $dnxcf_options['dnxcf_from_name'],
+ $dnxcf_options['dnxcf_from_email']
+ );
+ ?>
+<br />
+ <?php _e( 'so just make sure you whitelist this address in your mail client to avoid losing important messages.', 'dnxcf' ); ?>
</p>
-<?php }
+ <?php
+}
-function dnxcf_settings_privacy_section_text() { ?>
+function dnxcf_settings_privacy_section_text() {
+ ?>
<p><?php _e( 'Enter here the content of your privacy policy relative to the contact form.', 'dnxcf' ); ?></p>
-<?php }
+ <?php
+}
-function dnxcf_settings_googlemap_section_text() { ?>
+function dnxcf_settings_googlemap_section_text() {
+ ?>
<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>
-<?php }
+ <?php
+}
// Content type for email sent via this form
function dnxcf_setting_content_type_display() {
-$dnxcf_options = get_option( 'dnxcf_options' );
-// 1 = text/plain
-// 2 = text/html
-?>
-<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 />
-<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 />
-<span class="description"><?php _e('Send plain (text) or rich (html) messages.', 'dnxcf'); ?></span>
-<?php }
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ // 1 = text/plain
+ // 2 = text/html
+ ?>
+<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 />
+<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 />
+<span class="description"><?php _e( 'Send plain (text) or rich (html) messages.', 'dnxcf' ); ?></span>
+ <?php
+}
// Receiving email name
function dnxcf_setting_email_name_display() {
-$dnxcf_options = get_option( 'dnxcf_options' ); ?>
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
<input type="text" name="dnxcf_options[dnxcf_recv_name]" value="<?php echo $dnxcf_options['dnxcf_recv_name']; ?>" /><br />
-<span class="description"><?php _e('This is how you will be called in every email you will receive from this contact form.', 'dnxcf'); ?></span>
-<?php }
+<span class="description"><?php _e( 'This is how you will be called in every email you will receive from this contact form.', 'dnxcf' ); ?></span>
+ <?php
+}
// Receiving email address
function dnxcf_setting_email_address_display() {
-$dnxcf_options = get_option( 'dnxcf_options' ); ?>
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
<input type="email" name="dnxcf_options[dnxcf_recv_email]" value="<?php echo $dnxcf_options['dnxcf_recv_email']; ?>" /><br />
-<span class="description"><?php _e('If you leave this field empty the admin email address will be used.', 'dnxcf'); ?></span>
-<?php }
+<span class="description"><?php _e( 'If you leave this field empty the admin email address will be used.', 'dnxcf' ); ?></span>
+ <?php
+}
// Custom subject options
function dnxcf_setting_subject_display() {
-$dnxcf_options = get_option( 'dnxcf_options' ); ?>
-<textarea name="dnxcf_options[dnxcf_subject]" rows="10" cols="80" /><?php echo implode("\n", $dnxcf_options['dnxcf_subject']); ?></textarea><br />
-<span class="description"><?php _e('Insert one option per line. If you leave this area empty the default options will be used.', 'dnxcf'); ?></span>
-<?php }
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
+<textarea name="dnxcf_options[dnxcf_subject]" rows="10" cols="80" /><?php echo implode( "\n", $dnxcf_options['dnxcf_subject'] ); ?></textarea><br />
+<span class="description"><?php _e( 'Insert one option per line. If you leave this area empty the default options will be used.', 'dnxcf' ); ?></span>
+ <?php
+}
// Sender email address
function dnxcf_setting_mailfrom_mail_display() {
-$dnxcf_options = get_option( 'dnxcf_options' ); ?>
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
<input type="email" name="dnxcf_options[dnxcf_from_email]" value="<?php echo $dnxcf_options['dnxcf_from_email']; ?>" /><br />
-<span class="description"><?php _e('This is the email address from which you will receive communications.', 'dnxcf'); ?></span>
-<?php }
+<span class="description"><?php _e( 'This is the email address from which you will receive communications.', 'dnxcf' ); ?></span>
+ <?php
+}
// Sender name
function dnxcf_setting_mailfrom_name_display() {
-$dnxcf_options = get_option( 'dnxcf_options' ); ?>
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
<input type="text" name="dnxcf_options[dnxcf_from_name]" value="<?php echo $dnxcf_options['dnxcf_from_name']; ?>" /><br />
-<span class="description"><?php _e('This is the name associated to the above email address.', 'dnxcf'); ?></span>
-<?php }
+<span class="description"><?php _e( 'This is the name associated to the above email address.', 'dnxcf' ); ?></span>
+ <?php
+}
// Privacy Policy
function dnxcf_setting_privacy_display() {
-$dnxcf_options = get_option( 'dnxcf_options' ); ?>
-<textarea name="dnxcf_options[dnxcf_privacy]" rows="10" cols="80" /><?php echo wptexturize($dnxcf_options['dnxcf_privacy']); ?></textarea><br />
-<span class="description"><?php _e('The text of the privacy policy, Leave empty to disable the policy area in the form.', 'dnxcf'); ?></span>
-<?php }
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
+<textarea name="dnxcf_options[dnxcf_privacy]" rows="10" cols="80" /><?php echo wptexturize( $dnxcf_options['dnxcf_privacy'] ); ?></textarea><br />
+<span class="description"><?php _e( 'The text of the privacy policy, Leave empty to disable the policy area in the form.', 'dnxcf' ); ?></span>
+ <?php
+}
// api key
function dnxcf_setting_googlemap_apikey_display() {
-$dnxcf_options = get_option( 'dnxcf_options' );
-$dev_links = 'https://developers.google.com/maps/documentation/javascript/get-api-key'; ?>
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ $dev_links = 'https://developers.google.com/maps/documentation/javascript/get-api-key';
+ ?>
<input type="text" name="dnxcf_options[dnxcf_apikey]" value="<?php echo $dnxcf_options['dnxcf_apikey']; ?>" /><br />
-<span class="description"><?php _e('You need an API Key from the developers console in order to use Google Maps', 'dnxcf'); ?></span><br />
-<span class="description"><?php echo sprintf(__('check the <a href="%s">documentation</a> on the google developers platform.', 'dnxcf'), $dev_links ); ?></span><br />
-<span class="description"><?php _e('Leave empty to disable the display of a Google Map on the form.', 'dnxcf'); ?></span>
-<?php }
+<span class="description"><?php _e( 'You need an API Key from the developers console in order to use Google Maps', 'dnxcf' ); ?></span><br />
+<span class="description"><?php echo sprintf( __( 'check the <a href="%s">documentation</a> on the google developers platform.', 'dnxcf' ), $dev_links ); ?></span><br />
+<span class="description"><?php _e( 'Leave empty to disable the display of a Google Map on the form.', 'dnxcf' ); ?></span>
+ <?php
+}
// map message
function dnxcf_setting_googlemap_message_display() {
-$dnxcf_options = get_option( 'dnxcf_options' ); ?>
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
<input type="text" name="dnxcf_options[dnxcf_gmap_message]" value="<?php echo $dnxcf_options['dnxcf_gmap_message']; ?>" /><br />
-<span class="description"><?php _e('Address to be displayed as a popup inside the map. Leave empty to disable.', 'dnxcf'); ?></span>
-<?php }
+<span class="description"><?php _e( 'Address to be displayed as a popup inside the map. Leave empty to disable.', 'dnxcf' ); ?></span>
+ <?php
+}
// Longitude
function dnxcf_setting_googlemap_long_display() {
-$dnxcf_options = get_option( 'dnxcf_options' ); ?>
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
<input type="number" name="dnxcf_options[dnxcf_longitude]" value="<?php echo $dnxcf_options['dnxcf_longitude']; ?>" step="0.000001" /><br />
-<span class="description"><?php _e('Longitude value, eg. 16.290340', 'dnxcf'); ?></span><br />
-<span class="description"><?php _e('+/- 180 degrees value accepted', 'dnxcf'); ?></span>
-<?php }
+<span class="description"><?php _e( 'Longitude value, eg. 16.290340', 'dnxcf' ); ?></span><br />
+<span class="description"><?php _e( '+/- 180 degrees value accepted', 'dnxcf' ); ?></span>
+ <?php
+}
// Latitude
function dnxcf_setting_googlemap_lat_display() {
-$dnxcf_options = get_option( 'dnxcf_options' ); ?>
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
<input type="number" name="dnxcf_options[dnxcf_latitude]" value="<?php echo $dnxcf_options['dnxcf_latitude']; ?>" step="0.000001" /><br />
-<span class="description"><?php _e('Latitude value, eg. 38.269625.', 'dnxcf'); ?></span><br />
-<span class="description"><?php _e('+/- 90 degrees value accepted', 'dnxcf'); ?></span>
-<?php }
+<span class="description"><?php _e( 'Latitude value, eg. 38.269625.', 'dnxcf' ); ?></span><br />
+<span class="description"><?php _e( '+/- 90 degrees value accepted', 'dnxcf' ); ?></span>
+ <?php
+}
// our validation function
function dnxcf_setup_validate( $input ) {
- $dnxcf_options = get_option('dnxcf_options');
- $valid_input = $dnxcf_options;
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ $valid_input = $dnxcf_options;
- $submit = ( ! empty( $input['submit'] ) ? true : false );
- $reset = ( ! empty( $input['reset'] ) ? true : false );
+ $submit = ( ! empty( $input['submit'] ) ? true : false );
+ $reset = ( ! empty( $input['reset'] ) ? true : false );
- if($submit) {
- $default_options = dnxcf_set_options();
- // content type
- $valid_input['dnxcf_content_type'] = ( '1' == $input['dnxcf_content_type'] ? $default_options['dnxcf_content_type'] : "2" );
- // email address
- $valid_input['dnxcf_recv_name'] = ( '' == $input['dnxcf_recv_name'] ? $default_options['dnxcf_recv_name'] : sanitize_text_field($input['dnxcf_recv_name']) );
- $valid_input['dnxcf_recv_email'] = ( '' == $input['dnxcf_recv_email'] ? $default_options['dnxcf_recv_email'] : sanitize_email($input['dnxcf_recv_email']) );
- // subject options
- if ( '' == $input['dnxcf_subject'] ) {
- $valid_input['dnxcf_subject'] = $default_options['dnxcf_subject'];
- } else {
- $valid_input['dnxcf_subject'] = rtrim(esc_textarea( $input['dnxcf_subject'] ));
- $valid_input['dnxcf_subject'] = explode("\n", $valid_input['dnxcf_subject']);
- }
- // from email address and name
- $valid_input['dnxcf_from_email'] = ( '' == $input['dnxcf_from_email'] ? $default_options['dnxcf_from_email'] : sanitize_email($input['dnxcf_from_email']) );
- $valid_input['dnxcf_from_name'] = ( '' == $input['dnxcf_from_name'] ? $default_options['dnxcf_from_name'] : sanitize_text_field($input['dnxcf_from_name']) );
- // privacy policy
- $valid_html = array(
- 'a' => array(
- 'href' => array(),
- 'title' => array()
- ),
- 'br' => array(),
- 'em' => array(),
- 'strong' => array(),
- 'p' => array()
- );
- $valid_input['dnxcf_privacy'] = ( '' == $input['dnxcf_privacy'] ? false : wp_kses($input['dnxcf_privacy'], $valid_html) );
- // latitude and longitude
- $valid_input['dnxcf_gmap_message'] = ( '' == $input['dnxcf_gmap_message'] ? $default_options['dnxcf_gmap_message'] : sanitize_text_field($input['dnxcf_gmap_message']) );
- if ( '' != $input['dnxcf_latitude'] ) {
- $valid_input['dnxcf_latitude'] = ( preg_match("/^[-]?[0-8]?[0-9]\.\d+|[-]?90\.0+?/A", $input['dnxcf_latitude']) ? $input['dnxcf_latitude'] : '' );
- } else {
- $valid_input['dnxcf_latitude'] = '';
- }
- $valid_input['dnxcf_apikey'] = ( '' == $input['dnxcf_apikey'] ? $default_options['dnxcf_apikey'] : sanitize_html_class($input['dnxcf_apikey']) );
+ if ( $submit ) {
+ $default_options = dnxcf_set_options();
+ // content type
+ $valid_input['dnxcf_content_type'] = ( '1' == $input['dnxcf_content_type'] ? $default_options['dnxcf_content_type'] : '2' );
+ // email address
+ $valid_input['dnxcf_recv_name'] = ( '' == $input['dnxcf_recv_name'] ? $default_options['dnxcf_recv_name'] : sanitize_text_field( $input['dnxcf_recv_name'] ) );
+ $valid_input['dnxcf_recv_email'] = ( '' == $input['dnxcf_recv_email'] ? $default_options['dnxcf_recv_email'] : sanitize_email( $input['dnxcf_recv_email'] ) );
+ // subject options
+ if ( '' == $input['dnxcf_subject'] ) {
+ $valid_input['dnxcf_subject'] = $default_options['dnxcf_subject'];
+ } else {
+ $valid_input['dnxcf_subject'] = rtrim( esc_textarea( $input['dnxcf_subject'] ) );
+ $valid_input['dnxcf_subject'] = explode( "\n", $valid_input['dnxcf_subject'] );
+ }
+ // from email address and name
+ $valid_input['dnxcf_from_email'] = ( '' == $input['dnxcf_from_email'] ? $default_options['dnxcf_from_email'] : sanitize_email( $input['dnxcf_from_email'] ) );
+ $valid_input['dnxcf_from_name'] = ( '' == $input['dnxcf_from_name'] ? $default_options['dnxcf_from_name'] : sanitize_text_field( $input['dnxcf_from_name'] ) );
+ // privacy policy
+ $valid_html = array(
+ 'a' => array(
+ 'href' => array(),
+ 'title' => array(),
+ ),
+ 'br' => array(),
+ 'em' => array(),
+ 'strong' => array(),
+ 'p' => array(),
+ );
+ $valid_input['dnxcf_privacy'] = ( '' == $input['dnxcf_privacy'] ? false : wp_kses( $input['dnxcf_privacy'], $valid_html ) );
+ // latitude and longitude
+ $valid_input['dnxcf_gmap_message'] = ( '' == $input['dnxcf_gmap_message'] ? $default_options['dnxcf_gmap_message'] : sanitize_text_field( $input['dnxcf_gmap_message'] ) );
+ if ( '' != $input['dnxcf_latitude'] ) {
+ $valid_input['dnxcf_latitude'] = ( preg_match( '/^[-]?[0-8]?[0-9]\.\d+|[-]?90\.0+?/A', $input['dnxcf_latitude'] ) ? $input['dnxcf_latitude'] : '' );
+ } else {
+ $valid_input['dnxcf_latitude'] = '';
+ }
+ $valid_input['dnxcf_apikey'] = ( '' == $input['dnxcf_apikey'] ? $default_options['dnxcf_apikey'] : sanitize_html_class( $input['dnxcf_apikey'] ) );
- if ( '' != $input['dnxcf_longitude'] ) {
- $valid_input['dnxcf_longitude'] = ( preg_match("/[-]?1[0-7][0-9]\.\d+|[-]?[0-9]?[0-9]\.\d+|[-]?180\.0+?/A", $input['dnxcf_longitude']) ? $input['dnxcf_longitude'] : '' );
- } else {
- $valid_input['dnxcf_longitude'] = '';
- }
- } elseif ($reset) {
- $default_options = dnxcf_set_options();
- // content type
- $valid_input['dnxcf_content_type'] = $default_options['dnxcf_content_type'];
- // email address
- $valid_input['dnxcf_recv_name'] = $default_options['dnxcf_recv_name'];
- $valid_input['dnxcf_recv_email'] = $default_options['dnxcf_recv_email'];
- // subject options
- $valid_input['dnxcf_subject'] = $default_options['dnxcf_subject'];
- // from email address and name
- $valid_input['dnxcf_from_email'] = $default_options['dnxcf_from_email'];
- $valid_input['dnxcf_from_name'] = $default_options['dnxcf_from_name'];
- // subject options
- $valid_input['dnxcf_privacy'] = $default_options['dnxcf_privacy'];
- // latitude and longitude
- $valid_input['dnxcf_gmap_message'] = $default_options['dnxcf_gmap_message'];
- $valid_input['dnxcf_apikey'] = $default_options['dnxcf_apikey'];
- $valid_input['dnxcf_latitude'] = $default_options['dnxcf_latitude'];
- $valid_input['dnxcf_longitude'] = $default_options['dnxcf_longitude'];
- }
- return $valid_input;
+ if ( '' != $input['dnxcf_longitude'] ) {
+ $valid_input['dnxcf_longitude'] = ( preg_match( '/[-]?1[0-7][0-9]\.\d+|[-]?[0-9]?[0-9]\.\d+|[-]?180\.0+?/A', $input['dnxcf_longitude'] ) ? $input['dnxcf_longitude'] : '' );
+ } else {
+ $valid_input['dnxcf_longitude'] = '';
+ }
+ } elseif ( $reset ) {
+ $default_options = dnxcf_set_options();
+ // content type
+ $valid_input['dnxcf_content_type'] = $default_options['dnxcf_content_type'];
+ // email address
+ $valid_input['dnxcf_recv_name'] = $default_options['dnxcf_recv_name'];
+ $valid_input['dnxcf_recv_email'] = $default_options['dnxcf_recv_email'];
+ // subject options
+ $valid_input['dnxcf_subject'] = $default_options['dnxcf_subject'];
+ // from email address and name
+ $valid_input['dnxcf_from_email'] = $default_options['dnxcf_from_email'];
+ $valid_input['dnxcf_from_name'] = $default_options['dnxcf_from_name'];
+ // subject options
+ $valid_input['dnxcf_privacy'] = $default_options['dnxcf_privacy'];
+ // latitude and longitude
+ $valid_input['dnxcf_gmap_message'] = $default_options['dnxcf_gmap_message'];
+ $valid_input['dnxcf_apikey'] = $default_options['dnxcf_apikey'];
+ $valid_input['dnxcf_latitude'] = $default_options['dnxcf_latitude'];
+ $valid_input['dnxcf_longitude'] = $default_options['dnxcf_longitude'];
+ }
+ return $valid_input;
}
* Include settings options for our plugin
* @since 0.2
*/
-add_action('admin_menu', 'dnxcf_settings' );
+add_action( 'admin_menu', 'dnxcf_settings' );
function dnxcf_settings() {
- add_menu_page('danixland Contact Form Settings', __('Contact Form', 'dnxcf'), 'manage_options', 'dnxcf_options', 'dnxcf_settings_display', 'dashicons-testimonial');
+ add_menu_page( 'danixland Contact Form Settings', __( 'Contact Form', 'dnxcf' ), 'manage_options', 'dnxcf_options', 'dnxcf_settings_display', 'dashicons-testimonial' );
}
/**
* @since 0.2
*/
function dnxcf_settings_display() {
-?>
- <div class="wrap">
- <h2><?php _e('danixland Contact Form Set up', 'dnxcf') ?></h2>
- <form method="post" action="options.php">
- <?php
- settings_fields('dnxcf_options');
- do_settings_sections('dnxcf_options_sections');
- ?>
- <p class="submit">
- <input name="dnxcf_options[submit]" type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes', 'dnxcf') ?>" />
- <input name="dnxcf_options[reset]" type="submit" class="button-secondary" value="<?php esc_attr_e('Reset Defaults', 'dnxcf'); ?>" />
- </p>
- </form>
- </div>
-<?php
+ ?>
+ <div class="wrap">
+ <h2><?php _e( 'danixland Contact Form Set up', 'dnxcf' ); ?></h2>
+ <form method="post" action="options.php">
+ <?php
+ settings_fields( 'dnxcf_options' );
+ do_settings_sections( 'dnxcf_options_sections' );
+ ?>
+ <p class="submit">
+ <input name="dnxcf_options[submit]" type="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'dnxcf' ); ?>" />
+ <input name="dnxcf_options[reset]" type="submit" class="button-secondary" value="<?php esc_attr_e( 'Reset Defaults', 'dnxcf' ); ?>" />
+ </p>
+ </form>
+ </div>
+ <?php
}
/**
* @since 0.2
*/
function dnxcf_register_options() {
- require( dirname( __FILE__ ) . '/dnxcf_options-register.php' );
+ require( dirname( __FILE__ ) . '/dnxcf_options-register.php' );
}
-add_action('admin_init', 'dnxcf_register_options');
+add_action( 'admin_init', 'dnxcf_register_options' );
-<?php exit('<h2>Directory Access Prohibited</h2>'); ?>
\ No newline at end of file
+<?php exit( '<h2>Directory Access Prohibited</h2>' );
-<?php exit('<h2>Directory Access Prohibited</h2>'); ?>
\ No newline at end of file
+<?php exit( '<h2>Directory Access Prohibited</h2>' );
<?php
//if uninstall not called from WordPress exit
-if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
- exit();
+if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
+ exit();
+}
$options = 'dnxcf_options';
delete_option( $options );
-?>
\ No newline at end of file
+