diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/dnxcf_helper.php | 40 | ||||
| -rw-r--r-- | include/dnxcf_mail_template_danixland.php | 2 | ||||
| -rw-r--r-- | include/dnxcf_options-display.php | 88 | ||||
| -rw-r--r-- | include/dnxcf_options-register.php | 21 | ||||
| -rw-r--r-- | include/dnxcf_settings.php | 2 |
5 files changed, 29 insertions, 124 deletions
diff --git a/include/dnxcf_helper.php b/include/dnxcf_helper.php index d6b4aa0..50c3739 100644 --- a/include/dnxcf_helper.php +++ b/include/dnxcf_helper.php @@ -1,5 +1,5 @@ <?php -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); +defined( 'ABSPATH' ) || die( 'No script kiddies please!' ); // generate a unique code, allows for lenght parameter if ( ! function_exists( 'dnxcf_get_unique_code' ) ) { @@ -15,32 +15,6 @@ if ( ! function_exists( 'dnxcf_get_unique_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>'; - } -} -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; - } ?> -<script> - function dnxcf_send_code() { - //Send the shortcode to the editor - window.send_to_editor("[dnx_contactform]"); - } -</script> - <?php -} -add_action( 'admin_footer', 'dnxcf_insert_shortcode' ); - - // set default options for the plugin function dnxcf_set_options() { $defaults = array( @@ -60,10 +34,6 @@ function dnxcf_set_options() { // 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; @@ -106,10 +76,13 @@ function dnxcf_db_check() { } // helper function that sets the current DB Version for comparison +/* + * Latest DB version: 5 +*/ 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( 'DNXCF_CURRENT_DB_VERSION', 5 ); } } @@ -144,6 +117,9 @@ if ( dnxcf_update_from_email() ) { add_filter( 'wp_mail_from', 'dnxcf_update_from_email' ); } +/* + * Set the content type for the email +*/ function dnxcf_update_content_type() { global $dnxcf_options; $dnxcf_options = get_option( 'dnxcf_options' ); diff --git a/include/dnxcf_mail_template_danixland.php b/include/dnxcf_mail_template_danixland.php index 1c7d5b7..fe3d1a2 100644 --- a/include/dnxcf_mail_template_danixland.php +++ b/include/dnxcf_mail_template_danixland.php @@ -1,5 +1,5 @@ <?php -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); +defined( 'ABSPATH' ) || die( 'No script kiddies please!' ); /** * danixland-contact-form standard Template * Template Name = danixland diff --git a/include/dnxcf_options-display.php b/include/dnxcf_options-display.php index 4eb93de..24a6d15 100644 --- a/include/dnxcf_options-display.php +++ b/include/dnxcf_options-display.php @@ -1,13 +1,11 @@ <?php -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); -// usage: $id, $title, $callback, $page +defined( 'ABSPATH' ) || 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' ); @@ -17,35 +15,32 @@ add_settings_field( 'dnxcf_setting_subject_display', __( 'subject options?', 'dn 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> +<p><?php esc_html_e( 'Here you can change the content type of your emails, either html or plain text.', 'dnxcf' ); ?></p> <?php } 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> +<p><?php esc_html_e( 'This is the email address where you will receive all email from the contact form.', 'dnxcf' ); ?></p> <?php } 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> +<p><?php esc_html_e( 'These are the options that you are giving as a dropdown list to your users.', 'dnxcf' ); ?></p> <?php } function dnxcf_settings_mailfrom_section_text() { ?> <p> - <?php _e( 'Here you can set the sender email address for the contact form.', 'dnxcf' ); ?><br /> + <?php esc_html_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' ); + // translators: %1$s = from name inside email; $2$s = from email address echo sprintf( __( 'The emails you will receive will be from: <code>%1$s < %2$s ></code>', 'dnxcf' ), $dnxcf_options['dnxcf_from_name'], @@ -53,20 +48,14 @@ function dnxcf_settings_mailfrom_section_text() { ); ?> <br /> - <?php _e( 'so just make sure you whitelist this address in your mail client to avoid losing important messages.', 'dnxcf' ); ?> + <?php esc_html_e( 'so just make sure you whitelist this address in your mail client to avoid losing important messages.', 'dnxcf' ); ?> </p> <?php } 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 -} - -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> +<p><?php esc_html_e( 'Enter here the content of your privacy policy relative to the contact form.', 'dnxcf' ); ?></p> <?php } @@ -76,9 +65,9 @@ function dnxcf_setting_content_type_display() { // 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> +<input type="radio" name="dnxcf_options[dnxcf_content_type]" <?php checked( $dnxcf_options['dnxcf_content_type'], '1' ); ?> value='1' /> <?php esc_html_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 esc_html_e( 'text/html', 'dnxcf' ); ?><br /> +<span class="description"><?php esc_html_e( 'Send plain (text) or rich (html) messages.', 'dnxcf' ); ?></span> <?php } @@ -87,7 +76,7 @@ function dnxcf_setting_email_name_display() { $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> +<span class="description"><?php esc_html_e( 'This is how you will be called in every email you will receive from this contact form.', 'dnxcf' ); ?></span> <?php } @@ -96,7 +85,7 @@ function dnxcf_setting_email_address_display() { $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> +<span class="description"><?php esc_html_e( 'If you leave this field empty the admin email address will be used.', 'dnxcf' ); ?></span> <?php } @@ -105,7 +94,7 @@ 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> +<span class="description"><?php esc_html_e( 'Insert one option per line. If you leave this area empty the default options will be used.', 'dnxcf' ); ?></span> <?php } @@ -114,7 +103,7 @@ function dnxcf_setting_mailfrom_mail_display() { $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> +<span class="description"><?php esc_html_e( 'This is the email address from which you will receive communications.', 'dnxcf' ); ?></span> <?php } @@ -123,7 +112,7 @@ function dnxcf_setting_mailfrom_name_display() { $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> +<span class="description"><?php esc_html_e( 'This is the name associated to the above email address.', 'dnxcf' ); ?></span> <?php } @@ -132,47 +121,6 @@ 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 -} - -// 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'; - ?> -<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 -} - -// map message -function dnxcf_setting_googlemap_message_display() { - $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 -} - -// Longitude -function dnxcf_setting_googlemap_long_display() { - $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 -} - -// Latitude -function dnxcf_setting_googlemap_lat_display() { - $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> +<span class="description"><?php esc_html_e( 'The text of the privacy policy, Leave empty to disable the policy area in the form.', 'dnxcf' ); ?></span> <?php } diff --git a/include/dnxcf_options-register.php b/include/dnxcf_options-register.php index e540806..5731573 100644 --- a/include/dnxcf_options-register.php +++ b/include/dnxcf_options-register.php @@ -1,5 +1,5 @@ <?php -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); +defined( 'ABSPATH' ) || die( 'No script kiddies please!' ); // include the file with the actual markup for the options to display require( dirname( __FILE__ ) . '/dnxcf_options-display.php' ); @@ -48,20 +48,6 @@ function dnxcf_setup_validate( $input ) { '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 @@ -76,11 +62,6 @@ function dnxcf_setup_validate( $input ) { $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 12eb5db..5ed0954 100644 --- a/include/dnxcf_settings.php +++ b/include/dnxcf_settings.php @@ -1,5 +1,5 @@ <?php -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); +defined( 'ABSPATH' ) || die( 'No script kiddies please!' ); /** * Include settings options for our plugin * @since 0.2 |
