From 8c3e9b00bbeb0a3493d5b0e9b6cc4c68d413a4b0 Mon Sep 17 00:00:00 2001
From: danix
Date: Wed, 4 Nov 2020 12:10:15 +0100
Subject: [PATCH] Linted files
modificato: danixland-contact-form.php
modificato: include/dnxcf_helper.php
modificato: include/dnxcf_mail_template_danixland.php
modificato: include/dnxcf_options-display.php
modificato: include/dnxcf_options-register.php
modificato: include/dnxcf_settings.php
modificato: include/index.php
modificato: index.php
modificato: uninstall.php
---
danixland-contact-form.php | 417 +++++++++++-----------
include/dnxcf_helper.php | 205 +++++------
include/dnxcf_mail_template_danixland.php | 35 +-
include/dnxcf_options-display.php | 207 ++++++-----
include/dnxcf_options-register.php | 134 +++----
include/dnxcf_settings.php | 38 +-
include/index.php | 2 +-
index.php | 2 +-
uninstall.php | 7 +-
9 files changed, 543 insertions(+), 504 deletions(-)
diff --git a/danixland-contact-form.php b/danixland-contact-form.php
index 8367d0d..7d5c8bd 100644
--- a/danixland-contact-form.php
+++ b/danixland-contact-form.php
@@ -1,7 +1,7 @@
@@ -73,28 +73,29 @@ $popup_content = <<< DNX6655788EOT
DNX6655788EOT;
-?>
+ ?>
- 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 ) { ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- administrator.', 'dnxcf'), get_bloginfo('admin_email') ); ?>
-
-
-
-
- $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 ) {
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ administrator.', 'dnxcf' ), get_bloginfo( 'admin_email' ) ); ?>
+
- } else { // the post hasn't been submitted. Let's show the form
- global $dnxcf_options;
- $dnxcf_options = get_option('dnxcf_options');
-?>
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
+?>
diff --git a/include/dnxcf_helper.php b/include/dnxcf_helper.php
index ce1f230..d6b4aa0 100644
--- a/include/dnxcf_helper.php
+++ b/include/dnxcf_helper.php
@@ -2,155 +2,156 @@
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 '';
- }
+ $currentScreen = get_current_screen();
+ if ( $currentScreen->parent_base == 'edit' ) {
+ echo '';
+ }
}
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;
+ } ?>
- 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' );
diff --git a/include/dnxcf_mail_template_danixland.php b/include/dnxcf_mail_template_danixland.php
index 69766ac..1c7d5b7 100644
--- a/include/dnxcf_mail_template_danixland.php
+++ b/include/dnxcf_mail_template_danixland.php
@@ -1,4 +1,4 @@
-
@@ -882,9 +882,8 @@ function dnxcf_email_content( $data = array(), $posted = array() ) {
DNX44665312EOT;
- return $output;
+ return $output;
}
-?>
diff --git a/include/dnxcf_options-display.php b/include/dnxcf_options-display.php
index 28618e5..4eb93de 100644
--- a/include/dnxcf_options-display.php
+++ b/include/dnxcf_options-display.php
@@ -1,145 +1,178 @@
-
+function dnxcf_settings_email_address_section_text() {
+ ?>
-
+function dnxcf_settings_subject_section_text() {
+ ?>
-
+function dnxcf_settings_mailfrom_section_text() {
+ ?>
-
-%s < %s >', 'dnxcf' ),
- $dnxcf_options['dnxcf_from_name'],
- $dnxcf_options['dnxcf_from_email']
- );
-?>
-
+
+ %1$s < %2$s >', 'dnxcf' ),
+ $dnxcf_options['dnxcf_from_name'],
+ $dnxcf_options['dnxcf_from_email']
+ );
+ ?>
+
+
-
+function dnxcf_settings_privacy_section_text() {
+ ?>
-
+function dnxcf_settings_googlemap_section_text() {
+ ?>
Note: if the API Key value is missing the map will be disabled.', 'dnxcf' ); ?>
-
- value='1' />
- value='2' />
-
-
+ value='1' />
+ value='2' />
+
+
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
-
-
+
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
-
-
+
-
-
-
+
+
+
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
-
-
+
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
-
-
+
-
-
-
+
+
+
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ $dev_links = 'https://developers.google.com/maps/documentation/javascript/get-api-key';
+ ?>
-
-documentation on the google developers platform.', 'dnxcf'), $dev_links ); ?>
-
-
+documentation on the google developers platform.', 'dnxcf' ), $dev_links ); ?>
+
+
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
-
-
+
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
-
-
-
+
+
+ $dnxcf_options = get_option( 'dnxcf_options' );
+ ?>
-
-
-
+
+ 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;
}
diff --git a/include/dnxcf_settings.php b/include/dnxcf_settings.php
index b7c29e4..12eb5db 100644
--- a/include/dnxcf_settings.php
+++ b/include/dnxcf_settings.php
@@ -4,9 +4,9 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
* 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' );
}
/**
@@ -14,21 +14,21 @@ function dnxcf_settings() {
* @since 0.2
*/
function dnxcf_settings_display() {
-?>
-
-
+
+ Directory Access Prohibited'); ?>
\ No newline at end of file
+Directory Access Prohibited' );
diff --git a/index.php b/index.php
index cb66473..a618147 100644
--- a/index.php
+++ b/index.php
@@ -1 +1 @@
-Directory Access Prohibited'); ?>
\ No newline at end of file
+Directory Access Prohibited' );
diff --git a/uninstall.php b/uninstall.php
index a01d2bf..e544cb8 100644
--- a/uninstall.php
+++ b/uninstall.php
@@ -1,10 +1,11 @@
\ No newline at end of file
+
--
2.20.1