From b96bc7586a5d69d408041a66d40a483f837e5e39 Mon Sep 17 00:00:00 2001 From: danix Date: Wed, 4 Jul 2018 17:44:08 +0200 Subject: initial commit --- include/dnxcf_helper.php | 156 ++++++ include/dnxcf_mail_template_danixland.php | 890 ++++++++++++++++++++++++++++++ include/dnxcf_options-display.php | 145 +++++ include/dnxcf_options-register.php | 87 +++ include/dnxcf_settings.php | 41 ++ include/index.php | 1 + 6 files changed, 1320 insertions(+) create mode 100644 include/dnxcf_helper.php create mode 100644 include/dnxcf_mail_template_danixland.php create mode 100644 include/dnxcf_options-display.php create mode 100644 include/dnxcf_options-register.php create mode 100644 include/dnxcf_settings.php create mode 100644 include/index.php (limited to 'include') diff --git a/include/dnxcf_helper.php b/include/dnxcf_helper.php new file mode 100644 index 0000000..ce1f230 --- /dev/null +++ b/include/dnxcf_helper.php @@ -0,0 +1,156 @@ +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; + } ?> + + 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); +} + +// 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); +} + +// 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 ); + } +} + +// 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 ); + } +} + +// 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; +} +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; +} +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'); + + // 1 = text/plain + // 2 = text/html + $content_type = ( "1" == $dnxcf_options['dnxcf_content_type'] ) ? 'text/plain' : 'text/html'; + + 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 new file mode 100644 index 0000000..69766ac --- /dev/null +++ b/include/dnxcf_mail_template_danixland.php @@ -0,0 +1,890 @@ + + + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
+ + + + + + +
+ + + $site +
+
+
+
+
+ + + + +
+ + + + +
+ + + + + +
+

Hello, $ownname

+

you have been contacted by $dnxcf_name on $site

+
+
+ + + + +
+ + + + + +
+

message about "$dnxcf_subject"

+

$dnxcf_message

+
+
+ + + + +
+ + + + + +
+

Some details about $dnxcf_name: +

    +
  • Browser: $ua
  • +
  • Time: $time
  • +
  • IP Address: $host
  • +
+

+
+
+ + + + +
+ + + + + +
+
+

you can reply directly to this email

+
+
+
+ + + + +
+ + + + + +
+
+

plugin author support | WordPress Support Forum

+
+
+
+
+
+
+ + + +DNX44665312EOT; + + return $output; + +} + +?> + diff --git a/include/dnxcf_options-display.php b/include/dnxcf_options-display.php new file mode 100644 index 0000000..28618e5 --- /dev/null +++ b/include/dnxcf_options-display.php @@ -0,0 +1,145 @@ + +

+ +

+ +

+ +

+
+%s < %s >', 'dnxcf' ), + $dnxcf_options['dnxcf_from_name'], + $dnxcf_options['dnxcf_from_email'] + ); +?>
+ +

+ +

+ +

Note: if the API Key value is missing the map will be disabled.', 'dnxcf' ); ?>

+ + value='1' />
+ value='2' />
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+
+documentation on the google developers platform.', 'dnxcf'), $dev_links ); ?>
+ + +
+ + +
+
+ + +
+
+ + 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; +} + diff --git a/include/dnxcf_settings.php b/include/dnxcf_settings.php new file mode 100644 index 0000000..b7c29e4 --- /dev/null +++ b/include/dnxcf_settings.php @@ -0,0 +1,41 @@ + +
+

+
+ +

+ + +

+
+
+Directory Access Prohibited'); ?> \ No newline at end of file -- cgit v1.2.3