';
if ( isset( $form_builder->contact_name ) ) {
echo $form_builder->contact_name;
@@ -439,11 +550,19 @@ public function render_fields( $form_builder ) {
echo $form_builder->attachment;
}
+ if ( isset( $form_builder->contact_checkbox ) ) {
+ echo $form_builder->contact_checkbox;
+ }
+
+ echo '
';
}
/**
@@ -452,20 +571,27 @@ public function render_fields( $form_builder ) {
* @param PirateForms_PhpFormBuilder $form_builder The form builder object.
*/
public function render_errors( $form_builder ) {
+ echo empty( $form_builder->errors ) ? '' : $this->display_errors( $form_builder->errors );
+ }
+
+ /**
+ * Displays all the errors relevant to the form
+ *
+ * @param Array $errors The error messages.
+ */
+ private function display_errors( $errors ) {
$output = '';
- if ( ! empty( $form_builder->errors ) ) :
+ if ( ! empty( $errors ) ) {
$output .= '
';
- foreach ( $form_builder->errors as $err ) :
+ foreach ( $errors as $err ) {
$output .= '
';
- endforeach;
-
- endif;
-
- echo $output;
+ }
+ }
+ return apply_filters( 'pirate_forms_errors', $output, $errors );
}
/**
@@ -475,11 +601,19 @@ public function render_errors( $form_builder ) {
*/
public function render_thankyou( $form_builder ) {
if ( ! empty( $form_builder->thank_you_message ) ) {
- echo '
';
+ echo $this->display_thankyou( $form_builder->thank_you_message );
}
}
+ /**
+ * Displays the thank you message relevant to the form
+ *
+ * @param string $text The message.
+ */
+ private function display_thankyou( $text ) {
+ return apply_filters( 'pirate_forms_thankyou', sprintf( '
', $text ), $text );
+ }
+
/**
* Process the form after submission
*
@@ -498,48 +632,63 @@ public function template_redirect() {
* @since 1.0.0
* @throws Exception When file uploading fails.
*/
- public function send_email( $test = false ) {
+ public function send_email( $test = false, $ajax = false, $_post = null, $_files = null ) {
+ $post_params = $_POST;
+ $post_files = $_FILES;
+
+ if ( $ajax ) {
+ $post_params = $_post;
+ $post_files = $_files;
+ }
+ $this->_post = $post_params;
+ $this->_files = $post_files;
+
PirateForms_Util::session_start();
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'POST data = %s', print_r( $_POST, true ) ), 'debug', __FILE__, __LINE__ );
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'POST data = %s', print_r( $post_params, true ) ), 'debug', __FILE__, __LINE__ );
// If POST and honeypot are not set, beat it
- if ( empty( $_POST ) || ! isset( $_POST['honeypot'] ) ) {
+ if ( empty( $post_params ) || ! isset( $post_params['honeypot'] ) ) {
return false;
}
// separate the nonce from a form that is displayed in the widget vs. one that is not
- $nonce_append = isset( $_POST['pirate_forms_from_widget'] ) && intval( $_POST['pirate_forms_from_widget'] ) === 1 ? 'yes' : 'no';
+ $nonce_append = isset( $post_params['pirate_forms_from_widget'] ) && intval( $post_params['pirate_forms_from_widget'] ) === 1 ? 'yes' : 'no';
// Session variable for form errors
$error_key = wp_create_nonce( get_bloginfo( 'admin_email' ) . $nonce_append );
$_SESSION[ $error_key ] = array();
+ $form_id = isset( $post_params['pirate_forms_form_id'] ) ? $post_params['pirate_forms_form_id'] : 0;
+ $new_error_key = $nonce_append . '.' . $form_id;
- // If nonce is not valid, beat it
+ // If nonce is not valid, beat it.
if ( ! $test && 'yes' === PirateForms_Util::get_option( 'pirateformsopt_nonce' ) ) {
- if ( ! wp_verify_nonce( $_POST['wordpress-nonce'], get_bloginfo( 'admin_email' ) . $nonce_append ) ) {
+ if ( ! wp_verify_nonce( $post_params['wordpress-nonce'], get_bloginfo( 'admin_email' ) . $nonce_append ) ) {
$_SESSION[ $error_key ]['nonce'] = __( 'Nonce failed!', 'pirate-forms' );
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, 'Nonce failed', 'error', __FILE__, __LINE__ );
- return PirateForms_Util::save_error( $error_key, $nonce_append . '.' . $form_id );
+ return PirateForms_Util::save_error( $error_key, $new_error_key );
}
}
// If the honeypot caught a bear, beat it
- if ( ! empty( $_POST['honeypot'] ) ) {
+ if ( ! empty( $post_params['honeypot'] ) ) {
$_SESSION[ $error_key ]['honeypot'] = __( 'Form submission failed!', 'pirate-forms' );
- return PirateForms_Util::save_error( $error_key, $nonce_append . '.' . $form_id );
+ return PirateForms_Util::save_error( $error_key, $new_error_key );
}
- $form_id = isset( $_POST['pirate_forms_form_id'] ) ? $_POST['pirate_forms_form_id'] : 0;
$pirate_forms_options = PirateForms_Util::get_form_options( $form_id );
if ( ! $this->validate_spam( $error_key, $pirate_forms_options ) ) {
- return PirateForms_Util::save_error( $error_key, $nonce_append . '.' . $form_id );
+ return PirateForms_Util::save_error( $error_key, $new_error_key );
}
// Start the body of the contact email
+ $private_fields = array();
$body = array();
$body['heading'] = sprintf( __( 'Contact form submission from %s', 'pirate-forms' ), get_bloginfo( 'name' ) . ' (' . site_url() . ')' );
$body['body'] = array();
+ // lets collect the values for ALL potential magic tags in the form $tag_name => $tag_value e.g. 'name' => 'some name'.
+ // the tag name should be without the curly braces.
+ $body['magic_tags'] = array();
list( $pirate_forms_contact_email, $pirate_forms_contact_name, $pirate_forms_contact_subject, $msg ) = $this->validate_request( $error_key, $pirate_forms_options, $body );
@@ -564,185 +713,231 @@ public function send_email( $test = false ) {
if ( ! empty( $contact_ip ) ) {
$body['body'][ __( 'IP address', 'pirate-forms' ) ] = $contact_ip;
$body['body'][ __( 'IP search', 'pirate-forms' ) ] = "http://whatismyipaddress.com/ip/$contact_ip";
+ $body['magic_tags'] += array( 'ip' => $contact_ip );
+
+ $private_fields[] = __( 'IP address', 'pirate-forms' );
+ $private_fields[] = __( 'IP search', 'pirate-forms' );
}
// Sanitize and prepare referrer;
- if ( ! empty( $_POST['pirate-forms-contact-referrer'] ) ) {
- $body['body'][ __( 'Came from', 'pirate-forms' ) ] = sanitize_text_field( $_POST['pirate-forms-contact-referrer'] );
+ if ( ! empty( $post_params['pirate-forms-contact-referrer'] ) ) {
+ $page = sanitize_text_field( $post_params['pirate-forms-contact-referrer'] );
+ $body['body'][ __( 'Came from', 'pirate-forms' ) ] = $page;
+ $body['magic_tags'] += array( 'referer' => $page );
+
+ $private_fields[] = __( 'Came from', 'pirate-forms' );
}
// Show the page this contact form was submitted on
- $body['body'][ __( 'Sent from page', 'pirate-forms' ) ] = get_permalink( get_the_id() );
+ $permalink = get_permalink( get_the_id() );
+ $body['body'][ __( 'Sent from page', 'pirate-forms' ) ] = $permalink;
+ $body['magic_tags'] += array( 'permalink' => $permalink );
+
+ $private_fields[] = __( 'Sent from page', 'pirate-forms' );
// Check the blacklist
$blocked = PirateForms_Util::is_blacklisted( $error_key, $pirate_forms_contact_email, $contact_ip );
if ( $blocked ) {
- PirateForms_Util::save_error( $error_key, $nonce_append . '.' . $form_id );
- return false;
+ return PirateForms_Util::save_error( $error_key, $new_error_key );
}
if ( $this->is_spam( $pirate_forms_options, $contact_ip, get_permalink( get_the_id() ), $msg ) ) {
- $_SESSION[ $error_key ]['honeypot'] = __( 'Form submission failed!', 'pirate-forms' );
+ $_SESSION[ $error_key ]['honeypot'] = __( 'Form submission failed!!', 'pirate-forms' );
}
if ( ! empty( $_SESSION[ $error_key ] ) ) {
- PirateForms_Util::save_error( $error_key, $nonce_append . '.' . $form_id );
+ return PirateForms_Util::save_error( $error_key, $new_error_key );
+ }
+
+ $_SESSION[ 'success' . $new_error_key ] = sanitize_text_field( $pirate_forms_options['pirateformsopt_label_submit'] );
+
+ $site_email = sanitize_text_field( $pirate_forms_options['pirateformsopt_email'] );
+ if ( ! empty( $pirate_forms_contact_name ) ) :
+ $site_name = $pirate_forms_contact_name;
+ else :
+ $site_name = htmlspecialchars_decode( get_bloginfo( 'name' ) );
+ endif;
+ // Notification recipients
+ $site_recipients = sanitize_text_field( $pirate_forms_options['pirateformsopt_email_recipients'] );
+ $site_recipients = explode( ',', $site_recipients );
+ $site_recipients = array_map( 'trim', $site_recipients );
+ $site_recipients = array_map( 'sanitize_email', $site_recipients );
+ $site_recipients = implode( ',', $site_recipients );
+ // No name? Use the submitter email address, if one is present
+ if ( empty( $pirate_forms_contact_name ) ) {
+ $pirate_forms_contact_name = ! empty( $pirate_forms_contact_email ) ? $pirate_forms_contact_email : '[None given]';
+ }
+
+ // Need an email address for the email notification
+ $send_from = '';
+ if ( '[email]' == $site_email && ! empty( $pirate_forms_contact_email ) ) {
+ $send_from = $pirate_forms_contact_email;
+ } elseif ( ! empty( $site_email ) ) {
+ $send_from = $site_email;
} else {
- $_SESSION[ 'success' . $nonce_append . '.' . $form_id ] = sanitize_text_field( $pirate_forms_options['pirateformsopt_label_submit'] );
+ $send_from = PirateForms_Util::get_from_email();
+ }
+ $send_from_name = $site_name;
- $site_email = sanitize_text_field( $pirate_forms_options['pirateformsopt_email'] );
- if ( ! empty( $pirate_forms_contact_name ) ) :
- $site_name = $pirate_forms_contact_name;
- else :
- $site_name = htmlspecialchars_decode( get_bloginfo( 'name' ) );
- endif;
- // Notification recipients
- $site_recipients = sanitize_text_field( $pirate_forms_options['pirateformsopt_email_recipients'] );
- $site_recipients = explode( ',', $site_recipients );
- $site_recipients = array_map( 'trim', $site_recipients );
- $site_recipients = array_map( 'sanitize_email', $site_recipients );
- $site_recipients = implode( ',', $site_recipients );
- // No name? Use the submitter email address, if one is present
- if ( empty( $pirate_forms_contact_name ) ) {
- $pirate_forms_contact_name = ! empty( $pirate_forms_contact_email ) ? $pirate_forms_contact_email : '[None given]';
- }
+ // Send an email notification to the correct address
+ $headers = "From: $send_from_name <$send_from>\r\nReply-To: $pirate_forms_contact_name <$pirate_forms_contact_email>\r\nContent-type: text/html";
+ add_action( 'phpmailer_init', array( $this, 'phpmailer' ) );
- // Need an email address for the email notification
- $send_from = '';
- if ( '[email]' == $site_email && ! empty( $pirate_forms_contact_email ) ) {
- $send_from = $pirate_forms_contact_email;
- } elseif ( ! empty( $site_email ) ) {
- $send_from = $site_email;
- } else {
- $send_from = PirateForms_Util::get_from_email();
- }
- $send_from_name = $site_name;
+ $attachments = $this->get_attachments( $error_key, $pirate_forms_options, $body );
+ if ( is_bool( $attachments ) ) {
+ return PirateForms_Util::save_error( $error_key, $new_error_key );
+ }
- // Send an email notification to the correct address
- $headers = "From: $send_from_name <$send_from>\r\nReply-To: $pirate_forms_contact_name <$pirate_forms_contact_email>\r\nContent-type: text/html";
- add_action( 'phpmailer_init', array( $this, 'phpmailer' ) );
+ $subject = apply_filters( 'pirate_forms_subject', 'Contact on ' . htmlspecialchars_decode( get_bloginfo( 'name' ) ) );
+ if ( ! empty( $pirate_forms_contact_subject ) ) {
+ $subject = $pirate_forms_contact_subject;
+ }
- $attachments = $this->get_attachments( $error_key, $pirate_forms_options, $body );
- if ( is_bool( $attachments ) ) {
- return false;
+ $mail_body = ! empty( $pirate_forms_options['pirateformsopt_email_content'] ) ? $pirate_forms_options['pirateformsopt_email_content'] : PirateForms_Util::get_default_email_content( true, $form_id, true );
+ $mail_body = PirateForms_Util::replace_magic_tags( $mail_body, $body );
+
+ do_action( 'pirate_forms_before_sending', $pirate_forms_contact_email, $site_recipients, $subject, $mail_body, $headers, $attachments );
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'before sending email to = %s, subject = %s, body = %s, headers = %s, attachments = %s', $site_recipients, $subject, $mail_body, $headers, print_r( $attachments, true ) ), 'debug', __FILE__, __LINE__ );
+ $response = $this->finally_send_mail( $site_recipients, $subject, $mail_body, $headers, $attachments, true );
+ if ( ! $response ) {
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, 'Email not sent', 'debug', __FILE__, __LINE__ );
+ error_log( 'Email not sent' );
+ }
+ do_action( 'pirate_forms_after_sending', $pirate_forms_options, $response, $pirate_forms_contact_email, $site_recipients, $subject, $mail_body, $headers, $attachments );
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'after sending email, response = %s', $response ), 'debug', __FILE__, __LINE__ );
+
+ // delete the tmp directory
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
+ WP_Filesystem();
+ global $wp_filesystem;
+ $wp_filesystem->delete( $this->get_upload_tmp_dir(), true, 'd' );
+
+ // Should a confirm email be sent?
+ $confirm_body = stripslashes( trim( $pirate_forms_options['pirateformsopt_confirm_email'] ) );
+ $response_confirm = '';
+ if ( ! empty( $confirm_body ) && ! empty( $pirate_forms_contact_email ) ) {
+ // Removing entities
+ $confirm_body = htmlspecialchars_decode( $confirm_body );
+ $confirm_body = html_entity_decode( $confirm_body );
+ $confirm_body = str_replace( ''', "'", $confirm_body );
+ $send_from = PirateForms_Util::get_from_email();
+ if ( ! empty( $site_email ) && '[email]' !== $site_email ) {
+ $send_from = $site_email;
}
+ $site_name = htmlspecialchars_decode( get_bloginfo( 'name' ) );
+
+ $headers = "From: $site_name <$send_from>\r\nReply-To: $site_name <$send_from>";
+ $subject = $pirate_forms_options['pirateformsopt_label_submit'] . ' - ' . $site_name;
- $subject = 'Contact on ' . htmlspecialchars_decode( get_bloginfo( 'name' ) );
- if ( ! empty( $pirate_forms_contact_subject ) ) {
- $subject = $pirate_forms_contact_subject;
+ if ( isset( $pirate_forms_options['pirateformsopt_copy_email'] ) && 'yes' === $pirate_forms_options['pirateformsopt_copy_email'] ) {
+ $confirm_body = $this->append_original_email( $confirm_body, $body, $private_fields );
}
- $mail_body = apply_filters( 'pirate_forms_get_mail_body', $body );
- if ( is_array( $mail_body ) ) {
- $mail_body = PirateForms_Util::get_table( $mail_body );
+ do_action( 'pirate_forms_before_sending_confirm', $pirate_forms_contact_email, $pirate_forms_contact_email, $subject, $confirm_body, $headers );
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'before sending confirm email to = %s, subject = %s, body = %s, headers = %s', $pirate_forms_contact_email, $subject, $confirm_body, $headers ), 'debug', __FILE__, __LINE__ );
+ $response_confirm = $this->finally_send_mail( $pirate_forms_contact_email, $subject, $confirm_body, $headers, null, false );
+ do_action( 'pirate_forms_after_sending_confirm', $pirate_forms_options, $response_confirm, $pirate_forms_contact_email, $pirate_forms_contact_email, $subject, $confirm_body, $headers );
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'after sending confirm email response = %s', $response_confirm ), 'debug', __FILE__, __LINE__ );
+ if ( ! $response_confirm ) {
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, 'Confirm email not sent', 'debug', __FILE__, __LINE__ );
+ error_log( 'Confirm email not sent' );
}
+ }
- do_action( 'pirate_forms_before_sending', $pirate_forms_contact_email, $site_recipients, $subject, $mail_body, $headers, $attachments );
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'before sending email to = %s, subject = %s, body = %s, headers = %s, attachments = %s', $site_recipients, $subject, $mail_body, $headers, print_r( $attachments, true ) ), 'debug', __FILE__, __LINE__ );
- $response = $this->finally_send_mail( $site_recipients, $subject, $mail_body, $headers, $attachments, true );
- if ( ! $response ) {
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, 'Email not sent', 'debug', __FILE__, __LINE__ );
- error_log( 'Email not sent' );
+ /**
+ *********** Store the entries in the DB */
+ if ( 'yes' === $pirate_forms_options['pirateformsopt_store'] ) {
+ $new_post_id = wp_insert_post(
+ array(
+ 'post_type' => 'pf_contact',
+ 'post_title' => date( 'l, M j, Y', time() ) . ' by "' . $pirate_forms_contact_name . '"',
+ 'post_content' => $mail_body,
+ 'post_author' => 1,
+ 'post_status' => 'private',
+ )
+ );
+ if ( isset( $pirate_forms_contact_email ) && ! empty( $pirate_forms_contact_email ) ) {
+ add_post_meta( $new_post_id, 'Contact email', $pirate_forms_contact_email );
}
- do_action( 'pirate_forms_after_sending', $pirate_forms_options, $response, $pirate_forms_contact_email, $site_recipients, $subject, $mail_body, $headers, $attachments );
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'after sending email, response = %s', $response ), 'debug', __FILE__, __LINE__ );
-
- // delete the tmp directory
- require_once( ABSPATH . 'wp-admin/includes/file.php' );
- WP_Filesystem();
- global $wp_filesystem;
- $wp_filesystem->delete( $this->get_upload_tmp_dir(), true, 'd' );
-
- // Should a confirm email be sent?
- $confirm_body = stripslashes( trim( $pirate_forms_options['pirateformsopt_confirm_email'] ) );
- $response_confirm = '';
- if ( ! empty( $confirm_body ) && ! empty( $pirate_forms_contact_email ) ) {
- // Removing entities
- $confirm_body = htmlspecialchars_decode( $confirm_body );
- $confirm_body = html_entity_decode( $confirm_body );
- $confirm_body = str_replace( ''', "'", $confirm_body );
- $send_from = PirateForms_Util::get_from_email();
- if ( ! empty( $site_email ) && '[email]' !== $site_email ) {
- $send_from = $site_email;
- }
- $site_name = htmlspecialchars_decode( get_bloginfo( 'name' ) );
-
- $headers = "From: $site_name <$send_from>\r\nReply-To: $site_name <$send_from>";
- $subject = $pirate_forms_options['pirateformsopt_label_submit'] . ' - ' . $site_name;
-
- do_action( 'pirate_forms_before_sending_confirm', $pirate_forms_contact_email, $pirate_forms_contact_email, $subject, $confirm_body, $headers );
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'before sending confirm email to = %s, subject = %s, body = %s, headers = %s', $pirate_forms_contact_email, $subject, $confirm_body, $headers ), 'debug', __FILE__, __LINE__ );
- $response_confirm = $this->finally_send_mail( $pirate_forms_contact_email, $subject, $confirm_body, $headers, null, false );
- do_action( 'pirate_forms_after_sending_confirm', $pirate_forms_options, $response_confirm, $pirate_forms_contact_email, $pirate_forms_contact_email, $subject, $confirm_body, $headers );
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'after sending confirm email response = %s', $response_confirm ), 'debug', __FILE__, __LINE__ );
- if ( ! $response_confirm ) {
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, 'Confirm email not sent', 'debug', __FILE__, __LINE__ );
- error_log( 'Confirm email not sent' );
- }
+ add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'mail-status', $response ? 'true' : 'false' );
+ if ( defined( 'PIRATEFORMS_EMAIL_ERROR' ) ) {
+ add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'mail-status-reason', PIRATEFORMS_EMAIL_ERROR );
}
+ add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'confirm-mail-status', $response_confirm ? 'true' : 'false' );
+ do_action( 'pirate_forms_update_contact', $pirate_forms_options, $new_post_id );
+ }
- /**
- *********** Store the entries in the DB */
- if ( 'yes' === $pirate_forms_options['pirateformsopt_store'] ) {
- $new_post_id = wp_insert_post(
- array(
- 'post_type' => 'pf_contact',
- 'post_title' => date( 'l, M j, Y', time() ) . ' by "' . $pirate_forms_contact_name . '"',
- 'post_content' => $mail_body,
- 'post_author' => 1,
- 'post_status' => 'private',
- )
- );
- if ( isset( $pirate_forms_contact_email ) && ! empty( $pirate_forms_contact_email ) ) {
- add_post_meta( $new_post_id, 'Contact email', $pirate_forms_contact_email );
- }
- add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'mail-status', $response ? 'true' : 'false' );
- if ( defined( 'PIRATEFORMS_EMAIL_ERROR' ) ) {
- add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'mail-status-reason', PIRATEFORMS_EMAIL_ERROR );
- }
- add_post_meta( $new_post_id, PIRATEFORMS_SLUG . 'confirm-mail-status', $response_confirm ? 'true' : 'false' );
- do_action( 'pirate_forms_update_contact', $pirate_forms_options, $new_post_id );
+ do_action( 'pirate_forms_after_processing', $response );
+
+ if ( ! $test ) {
+ $pirate_forms_current_theme = wp_get_theme();
+ $is_our_theme = array_intersect(
+ array(
+ 'Zerif Lite',
+ 'Zerif PRO',
+ 'Hestia Pro',
+ ), array( $pirate_forms_current_theme->name, $pirate_forms_current_theme->parent_theme )
+ );
+
+ if ( $ajax ) {
+ return true;
}
- do_action( 'pirate_forms_after_processing', $response );
+ $redirect_to = null;
+ $scroll_to = isset( $post_params['pirate_forms_from_form'] ) ? $post_params['pirate_forms_from_form'] : '';
- if ( ! $test ) {
- $pirate_forms_current_theme = wp_get_theme();
- $is_our_theme = array_intersect(
+ /* If a Thank you page is selected, redirect to that page */
+ if ( $pirate_forms_options['pirateformsopt_thank_you_url'] ) {
+ $redirect_id = intval( $pirate_forms_options['pirateformsopt_thank_you_url'] );
+ $redirect = get_permalink( $redirect_id );
+ if ( ! empty( $redirect ) ) {
+ $redirect_to = $redirect;
+ }
+ } elseif ( $is_our_theme ) {
+ // the fragment identifier should always be the last argument, otherwise the thank you message will not show.
+ // the fragment identifier is called pcf here so that the URL can tell us if our theme was recognized.
+ $redirect_to = add_query_arg(
+ array(
+ 'done' => 'done',
+ 'pcf' => "#$scroll_to",
+ ), $_SERVER['HTTP_REFERER']
+ );
+ } elseif ( isset( $_SERVER['HTTP_REFERER'] ) ) {
+ // the fragment identifier is called pf here so that the URL can tell us if this is a not-our theme case.
+ $redirect_to = add_query_arg(
array(
- 'Zerif Lite',
- 'Zerif PRO',
- 'Hestia Pro',
- ), array( $pirate_forms_current_theme->name, $pirate_forms_current_theme->parent_theme )
+ 'done' => 'done',
+ 'pf' => "#$scroll_to",
+ ), $_SERVER['HTTP_REFERER']
);
+ }
- $redirect_to = null;
+ if ( $redirect_to ) {
+ wp_safe_redirect( $redirect_to );
+ exit();
+ }
+ }
+ }
- /* If a Thank you page is selected, redirect to that page */
- if ( $pirate_forms_options['pirateformsopt_thank_you_url'] ) {
- $redirect_id = intval( $pirate_forms_options['pirateformsopt_thank_you_url'] );
- $redirect = get_permalink( $redirect_id );
- if ( ! empty( $redirect ) ) {
- $redirect_to = $redirect;
- }
- } elseif ( $is_our_theme ) {
- // the fragment identifier should always be the last argument, otherwise the thank you message will not show.
- $redirect_to = add_query_arg(
- array(
- 'done' => 'done',
- 'pcf' => '1#contact',
- ), $_SERVER['HTTP_REFERER']
- );
- } elseif ( isset( $_SERVER['HTTP_REFERER'] ) ) {
- $redirect_to = add_query_arg( array( 'done' => 'done' ), $_SERVER['HTTP_REFERER'] );
- }
+ /**
+ * Appends the publicly displayed fields to the confirmation email.
+ *
+ * @param string $confirm_body The confirmation body.
+ * @param array $body The collected body fields.
+ * @param array $private_fields The private fields that should not be included from the body fields.
+ */
+ private function append_original_email( $confirm_body, $body, $private_fields ) {
+ $lines = array();
+ $lines[] = '------ Original Email ------';
- if ( $redirect_to ) {
- wp_safe_redirect( $redirect_to );
- exit();
- }
+ foreach ( $body['body'] as $field => $value ) {
+ if ( in_array( $field, $private_fields ) ) {
+ continue;
}
+ $lines[] = "$field : $value";
}
+
+ return $confirm_body . implode( '
', $lines );
}
/**
@@ -787,10 +982,10 @@ function validate_spam( $error_key, $pirate_forms_options ) {
$pirateformsopt_recaptcha_sitekey = $pirate_forms_options['pirateformsopt_recaptcha_sitekey'];
$pirateformsopt_recaptcha_secretkey = $pirate_forms_options['pirateformsopt_recaptcha_secretkey'];
if ( ! empty( $pirateformsopt_recaptcha_secretkey ) && ! empty( $pirateformsopt_recaptcha_sitekey ) ) {
- $captcha = $_POST['g-recaptcha-response'];
+ $captcha = $this->_post['g-recaptcha-response'];
}
if ( ! $captcha ) {
- $_SESSION[ $error_key ]['pirate-forms-captcha'] = __( 'Wrong reCAPTCHA', 'pirate-forms' );
+ $_SESSION[ $error_key ]['pirate-forms-captcha'] = __( 'Invalid CAPTCHA', 'pirate-forms' );
return false;
}
@@ -802,12 +997,12 @@ function validate_spam( $error_key, $pirate_forms_options ) {
$result = json_decode( $response_body, true );
endif;
if ( isset( $result['success'] ) && ( $result['success'] == false ) ) {
- $_SESSION[ $error_key ]['pirate-forms-captcha'] = __( 'Wrong reCAPTCHA', 'pirate-forms' );
+ $_SESSION[ $error_key ]['pirate-forms-captcha'] = __( 'Incorrect CAPTCHA', 'pirate-forms' );
return false;
}
} elseif ( 'custom' === $pirateformsopt_recaptcha_field ) {
- if ( isset( $_POST['xobkcehc'] ) && wp_verify_nonce( $_POST['xobkcehc'], PIRATEFORMS_NAME ) ) {
+ if ( isset( $this->_post['xobkcehc'] ) && wp_verify_nonce( $this->_post['xobkcehc'], PIRATEFORMS_NAME ) ) {
return true;
}
@@ -834,7 +1029,8 @@ function validate_request( $error_key, $pirate_forms_options, &$body ) {
$fields = array( 'name', 'email', 'subject', 'message' );
foreach ( $fields as $field ) {
- $value = isset( $_POST[ 'pirate-forms-contact-' . $field ] ) ? sanitize_text_field( trim( $_POST[ 'pirate-forms-contact-' . $field ] ) ) : '';
+ $value = isset( $this->_post[ 'pirate-forms-contact-' . $field ] ) ? sanitize_text_field( trim( $this->_post[ 'pirate-forms-contact-' . $field ] ) ) : '';
+ $body['magic_tags'] += array( $field => $value );
if ( 'req' === $pirate_forms_options[ 'pirateformsopt_' . $field . '_field' ] && empty( $value ) ) {
$_SESSION[ $error_key ][ 'pirate-forms-contact-' . $field ] = $pirate_forms_options[ 'pirateformsopt_label_err_' . $field ];
} elseif ( ! empty( $value ) ) {
@@ -859,11 +1055,11 @@ function validate_request( $error_key, $pirate_forms_options, &$body ) {
if ( ! $customize ) {
// new lite, old pro
$temp = '';
- $temp = apply_filters( 'pirate_forms_validate_request', $temp, $error_key, $pirate_forms_options );
+ $temp = apply_filters( 'pirate_forms_validate_request', $temp, $error_key, $pirate_forms_options, $this->_post, $this->_files );
$body['rows'] = $temp;
} else {
// new lite, new pro
- $body = apply_filters( 'pirate_forms_validate_request', $body, $error_key, $pirate_forms_options );
+ $body = apply_filters( 'pirate_forms_validate_request', $body, $error_key, $pirate_forms_options, $this->_post, $this->_files );
}
return array( $contact_email, $contact_name, $contact_subject, $message );
@@ -873,6 +1069,10 @@ function validate_request( $error_key, $pirate_forms_options, &$body ) {
* Check with akismet if the message is spam.
*/
function is_spam( $pirate_forms_options, $ip, $page_url, $msg ) {
+ if ( 'yes' !== PirateForms_Util::get_option( 'pirateformsopt_akismet' ) ) {
+ return false;
+ }
+
// check if akismet is installed and key provided
$key = get_option( 'wordpress_api_key' );
if ( empty( $key ) ) {
@@ -920,25 +1120,24 @@ function is_spam( $pirate_forms_options, $ip, $page_url, $msg ) {
*
* @throws Exception When file uploading fails.
*/
- function get_attachments( $error_key, $pirate_forms_options, &$body ) {
+ private function get_attachments( $error_key, $pirate_forms_options, &$body ) {
$attachments = array();
$has_files = $pirate_forms_options['pirateformsopt_attachment_field'];
if ( ! empty( $has_files ) ) {
$uploads_dir = $this->get_upload_tmp_dir();
$uploads_dir = $this->maybe_add_random_dir( $uploads_dir );
- foreach ( $_FILES as $label => $file ) {
+ $_files = $this->_files;
+
+ foreach ( $_files as $label => $file ) {
if ( empty( $file['name'] ) ) {
continue;
}
/* Validate file type */
- $file_types_allowed = implode( '|', apply_filters( 'pirate_forms_allowed_file_types', explode( '|', 'jpg|jpeg|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv|xls|xlsx|txt' ) ) );
- $pirate_forms_file_types_allowed = $file_types_allowed;
- $pirate_forms_file_types_allowed = trim( $pirate_forms_file_types_allowed, '|' );
- $pirate_forms_file_types_allowed = '(' . $pirate_forms_file_types_allowed . ')';
- $pirate_forms_file_types_allowed = '/\.' . $pirate_forms_file_types_allowed . '$/i';
+ $allowed = implode( '|', apply_filters( 'pirate_forms_allowed_file_types', self::$_file_types_allowed ) );
+ $pirate_forms_file_types_allowed = '/\.(' . trim( $allowed, '|' ) . ')$/i';
if ( ! preg_match( $pirate_forms_file_types_allowed, $file['name'] ) ) {
- do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'file invalid: expected %s got %s', $file_types_allowed, $file['name'] ), 'error', __FILE__, __LINE__ );
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'file invalid: expected %s got %s', $allowed, $file['name'] ), 'error', __FILE__, __LINE__ );
$_SESSION[ $error_key ]['pirate-forms-upload-failed-type'] = sprintf( __( 'Uploaded file type is not allowed for %s', 'pirate-forms' ), $file['name'] );
return false;
@@ -978,6 +1177,7 @@ function get_attachments( $error_key, $pirate_forms_options, &$body ) {
$files[] = basename( $file );
}
$body['body'][ __( 'Attachment', 'pirate-forms' ) ] = implode( ',', $files );
+ $body['magic_tags'] += array( 'attachments' => implode( ',', $files ) );
}
do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'finally attaching attachment(s): %s', print_r( $attachments, true ) ), 'info', __FILE__, __LINE__ );
@@ -1126,7 +1326,11 @@ public function widget_text_filter( $content ) {
* @param object $phpmailer PHPMailer object.
*/
function phpmailer( $phpmailer ) {
- $pirate_forms_options = PirateForms_Util::get_form_options( isset( $_POST['pirate_forms_form_id'] ) && ! empty( $_POST['pirate_forms_form_id'] ) ? $_POST['pirate_forms_form_id'] : null );
+ $id = null;
+ if ( isset( $this->_post['pirate_forms_form_id'] ) && ! empty( $this->_post['pirate_forms_form_id'] ) ) {
+ $id = $this->_post['pirate_forms_form_id'];
+ }
+ $pirate_forms_options = PirateForms_Util::get_form_options( $id );
$pirateformsopt_use_smtp = $pirate_forms_options['pirateformsopt_use_smtp'];
$pirateformsopt_smtp_host = $pirate_forms_options['pirateformsopt_smtp_host'];
$pirateformsopt_smtp_port = $pirate_forms_options['pirateformsopt_smtp_port'];
@@ -1188,4 +1392,58 @@ public function compatibility_class( $elements ) {
return $elements;
}
+
+ /**
+ * Register REST endpoints.
+ */
+ public function register_endpoint() {
+ register_rest_route(
+ PIRATEFORMS_SLUG . '/v' . intval( PIRATEFORMS_API_VERSION ),
+ '/send_email/',
+ array(
+ 'methods' => 'POST',
+ 'callback' => array( $this, 'send_email_ajax' ),
+ )
+ );
+ }
+
+ /**
+ * The REST endpoint for sending email.
+ */
+ public function send_email_ajax( WP_REST_Request $request ) {
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'calling ajax with %s, %s', print_r( $request->get_params(), true ), print_r( $request->get_file_params(), true ) ), 'debug', __FILE__, __LINE__ );
+
+ $return = $this->send_email( false, true, $request->get_params(), $request->get_file_params() );
+ $form_id = intval( $request->get_param( 'pirate_forms_form_id' ) );
+
+ // errors?
+ if ( is_bool( $return ) && ! $return ) {
+ $nonce_append = intval( $request->get_param( 'pirate_forms_from_widget' ) ) === 1 ? 'yes' : 'no';
+ $errors = $_SESSION[ 'error' . $nonce_append . '.' . $form_id ];
+ if ( $errors ) {
+ $messages = array();
+ foreach ( $errors as $k => $v ) {
+ $messages[] = $v;
+ }
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'got errors %s', print_r( $messages, true ) ), 'debug', __FILE__, __LINE__ );
+ return new WP_REST_Response( array( 'error' => $this->display_errors( $messages ) ), 500 );
+ }
+ }
+
+ // redirect?
+ $pirate_forms_options = PirateForms_Util::get_form_options( $form_id );
+ if ( $pirate_forms_options['pirateformsopt_thank_you_url'] ) {
+ $redirect_id = intval( $pirate_forms_options['pirateformsopt_thank_you_url'] );
+ $redirect = get_permalink( $redirect_id );
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'redirecting to %s', $redirect ), 'debug', __FILE__, __LINE__ );
+ if ( ! empty( $redirect ) ) {
+ return new WP_REST_Response( array( 'redirect' => $redirect ), 200 );
+ }
+ }
+
+ // thank you message.
+ $message = $this->display_thankyou( sanitize_text_field( $pirate_forms_options['pirateformsopt_label_submit'] ) );
+ do_action( 'themeisle_log_event', PIRATEFORMS_NAME, sprintf( 'thankyou message: %s', $message ), 'debug', __FILE__, __LINE__ );
+ return new WP_REST_Response( array( 'message' => $message ), 200 );
+ }
}
diff --git a/public/css/front.css b/public/css/front.css
index 49cc9fe..eeca7ad 100644
--- a/public/css/front.css
+++ b/public/css/front.css
@@ -1,16 +1,12 @@
/*
-Version: 2.2.3
+Version: 2.4.1
*/
-.pirate_forms_wrap .form_field_wrap {
+.pirate_forms_wrap .form_field_wrap,
+.widget .pirate_forms_wrap .form_field_wrap {
margin-bottom: 20px;
}
-.pirate-forms-g-recaptcha {
- display: none;
-}
-
.pirate_forms_wrap {
- float: left;
width: 100%;
}
@@ -20,77 +16,111 @@ Version: 2.2.3
margin-bottom: 20px;
}
+.widget .form_field_wrap,
.sidebar .form_field_wrap,
.sidebar-wrap .form_field_wrap,
#sidebar-secondary .form_field_wrap {
width: 100%;
+ max-width: 100%;
}
-.sidebar .pirate-forms-submit-button,
-.sidebar-wrap .pirate-forms-submit-button,
-#sidebar-secondary .pirate-forms-submit-button {
- float: left !important;
- width: 100%;
- margin-left: 0;
-}
-
-.sidebar .pirate_forms_wrap label,
-.sidebar-wrap .pirate_forms_wrap label,
-#sidebar-secondary .pirate_forms_wrap label {
- display: none;
-}
-
-.pirate_forms_clearfix {
+.pirate_forms_clearfix,
+.pirate-forms-fields-container:after,
+.pirate-forms-file-upload-wrapper:after {
+ display: block;
+ visibility: hidden;
clear: both;
+ height: 0;
+ font-size: 0;
+ content: " ";
}
.contact_submit_wrap {
text-align: right;
}
-.pirate-forms-file-upload-hidden {
- display: none;
- visibility: hidden;
- position: absolute;
- left: -9999px;
+.pirate-forms-maps-custom {
+ min-width: 150px;
}
-.pirate-forms-file-upload {
- display: block;
+.pirate-forms-maps-custom input {
+ display: inline;
width: auto;
}
-.pirate-forms-file-upload label {
- display: block;
- margin-bottom: 5px;
+.pirate-forms-maps-custom label {
+ display: inline;
+ cursor: pointer;
}
-.pirate-forms-file-upload-wrapper {
- position: relative;
- margin-bottom: 5px;
+.pirate-forms-maps-custom span {
+ margin-left: 5px;
}
-.pirate-forms-file-upload-input {
- float: left;
- width: 70% !important;
- border: none !important;
- outline: none !important;
- -webkit-transition: all 0.2s ease-in;
- transition: all 0.2s ease-in;
- /* IE 9 Fix */
+.pirate-forms-fields-container .form_field_wrap {
+ box-sizing: border-box;
+ padding-right: 15px;
+ padding-left: 15px;
}
-.pirate-forms-file-upload-input:hover,
-.pirate-forms-file-upload-input:focus {
- outline: none;
+.pirate_forms_three_inputs_wrap .form_field_wrap input {
+ box-sizing: border-box;
+ width: 100%;
+ max-width: 100%;
+ margin: 0;
+}
+
+.pirate-forms-fields-container .form_field_wrap textarea,
+.pirate-forms-fields-container .form_field_wrap select {
+ width: 100%;
+ max-width: 100%;
+ margin: 0;
}
-.pirate-forms-file-upload-button {
+.pirate_forms_wrap .form_field_wrap .pirate-forms-submit-button {
display: inline-block;
+ width: auto;
+}
+
+.pirate_forms_wrap .pirate-forms-footer {
+ display: table;
float: left;
- margin-left: -1px;
+ width: 100%;
+}
+
+.pirate_forms_wrap .pirate-forms-footer .form_field_wrap {
+ display: table-cell;
+ float: none;
+ width: auto;
+ margin: 0;
+ padding-bottom: 10px;
+ vertical-align: middle;
+}
+
+.pirate_forms_wrap .pirate_forms_three_inputs_wrap input[type=checkbox] {
+ display: inline-block;
+ width: auto;
+ height: inherit;
+}
+
+.pf-checkbox-label {
+ display: inline;
cursor: pointer;
- /* IE 9 Fix */
- -webkit-transition: all 0.2s ease-in;
- transition: all 0.2s ease-in;
+}
+
+.pf-checkbox-label span {
+ margin-left: 5px;
+}
+
+@media (max-width: 480px) {
+ .pirate_forms_wrap .pirate-forms-footer .form_field_wrap,
+ .pirate_forms_wrap .form_field_wrap .pirate-forms-submit-button {
+ display: block;
+ width: 100%;
+ }
+
+ .pirate_forms_wrap .pirate-forms-footer .pirateform_wrap_classes_spam_wrap,
+ .pirate_forms_wrap .pirate-forms-footer .form_captcha_wrap {
+ margin-bottom: 20px;
+ }
}
diff --git a/public/js/custom-spam.js b/public/js/custom-spam.js
new file mode 100644
index 0000000..da09a7f
--- /dev/null
+++ b/public/js/custom-spam.js
@@ -0,0 +1,41 @@
+/* global pf */
+/* global jQuery */
+(function($, pf){
+
+ $(document).ready(function() {
+ onDocumentReady();
+ });
+
+ $(window).load(function() {
+ onWindowLoad();
+ });
+
+ function onDocumentReady() {
+ // fired when a form is changed from the inspector.
+ if(pf.spam.gutenberg === 1){
+ jQuery('body').delegate('.pirate-forms-maps-custom', 'addCustomSpam', function(){
+ var i = 0;
+ addCustomSpam(i++, jQuery(this));
+ });
+ }
+
+ // for the front end.
+ jQuery('.pirate-forms-maps-custom').each(function(i){
+ addCustomSpam(i, jQuery(this));
+ });
+ }
+
+ function onWindowLoad() {
+ // fired when a saved form is loaded in gutenberg.
+ if(pf.spam.gutenberg === 1){
+ jQuery('.pirate-forms-maps-custom').each(function(i){
+ addCustomSpam(i, jQuery(this));
+ });
+ }
+ }
+
+ function addCustomSpam(i, object){
+ var $id = 'xobkcehc-' + i;
+ object.empty().html(jQuery('
'));
+ }
+})(jQuery, pf);
diff --git a/public/js/scripts-general.js b/public/js/scripts-general.js
deleted file mode 100644
index b10291c..0000000
--- a/public/js/scripts-general.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/* global pirateFormsObject */
-/* global jQuery */
-jQuery(document).ready(function() {
-
- var session_var = pirateFormsObject.errors;
-
- if( (typeof session_var !== 'undefined') && (session_var !== '') && (typeof jQuery('#contact') !== 'undefined') && (typeof jQuery('#contact').offset() !== 'undefined') ) {
-
- jQuery('html, body').animate({
- scrollTop: jQuery('#contact').offset().top
- }, 'slow');
- }
-
- if(jQuery('.pirate-forms-maps-custom').length > 0){
- jQuery('.pirate-forms-maps-custom').html(jQuery('
' + pirateFormsObject.spam.label + ''));
- }
-
-});
diff --git a/public/js/scripts.js b/public/js/scripts.js
index d31f14e..e38ee42 100644
--- a/public/js/scripts.js
+++ b/public/js/scripts.js
@@ -1,38 +1,116 @@
/* global jQuery */
-jQuery(document).ready(function() {
+/* global pirateFormsObject */
- /* show/hide reCaptcha */
+(function($, pf){
- var thisOpen = false;
- jQuery('.pirate_forms .form-control').each(function(){
- if ( jQuery(this).val().length > 0 ){
- thisOpen = true;
- jQuery('.zerif-g-recaptcha').css('display','block').delay(1000).css('opacity','1');
- return false;
- }
+ $( document ).ready( function () {
+ onDocumentReady();
});
- if ( thisOpen === false && (typeof jQuery('.pirate_forms textarea').val() !== 'undefined') && (jQuery('.pirate_forms textarea').val().length > 0) ) {
- thisOpen = true;
- jQuery('.pirate-forms-g-recaptcha').css('display','block').delay(1000).css('opacity','1');
- }
- jQuery('.pirate_forms input, .pirate_forms textarea').focus(function(){
- if ( !jQuery('.pirate-forms-g-recaptcha').hasClass('recaptcha-display') ) {
- jQuery('.pirate-forms-g-recaptcha').css('display','block').delay(1000).css('opacity','1');
- }
+
+ $( window ).load( function () {
+ onWindowLoad();
});
- jQuery('.pirate-forms-file-upload-button').on('click', function () {
- var $button = jQuery(this);
- $button.parent().find('input[type=file]').on('change', function(){
- $button.parent().find('input[type=text]').val(jQuery(this).val()).change();
+ function onDocumentReady() {
+ 'use strict';
+
+ // file upload behavior.
+ $( '.pirate-forms-file-upload-button' ).on( 'click', function () {
+ var $button = $( this );
+ $button.parent().find( 'input[type=file]' ).on( 'change', function () {
+ $button.parent().find( 'input[type=text]' ).val( $( this ).val() ).change();
+ } );
+ $button.parent().find( 'input[type=file]' ).focus().click();
+ } );
+
+ $( '.pirate-forms-file-upload-input' ).on( 'click', function () {
+ $( this ).parent().find( '.pirate-forms-file-upload-button' ).trigger( 'click' );
+ } );
+ $( '.pirate-forms-file-upload-input' ).on( 'focus', function () {
+ $( this ).blur();
+ } );
+
+ // show errors.
+ var session_var = pf.errors;
+ if( (typeof session_var !== 'undefined') && (session_var !== '') && (typeof $('#contact') !== 'undefined') && (typeof $('#contact').offset() !== 'undefined') ) {
+ $('html, body').animate({
+ scrollTop: $('#contact').offset().top
+ }, 'slow');
+ }
+
+ // support ajax forms.
+ $('.pirate-forms-submit-button-ajax').closest('form').submit(function(){
+ var form = $(this);
+ var formData = new FormData(form[0]);
+ ajaxStart( form );
+
+ // remove the dynamic containers.
+ $('div.pirate-forms-ajax').remove();
+
+ $.ajax({
+ url: pf.rest.submit.url,
+ data: formData,
+ type: 'POST',
+ dataType: 'json',
+ contentType: false,
+ processData: false,
+ beforeSend: function ( xhr ) {
+ xhr.setRequestHeader( 'X-WP-Nonce', pf.rest.nonce );
+ },
+ success: function(data){
+ //console.log("success");
+ //console.log(data);
+ form.find('input').val('');
+ form.find('select').val('');
+ form.find('input[type="checkbox"]').removeAttr('checked');
+ form.find('input[type="radio"]').removeAttr('checked');
+ var $time = new Date().getTime();
+
+ if(data.message){
+ form.closest('.pirate_forms_wrap').before('
');
+ $('#' + $time).append(data.message);
+ }else if(data.redirect){
+ location.href = data.redirect;
+ }
+ },
+ error: function(data){
+ //console.log("no");
+ //console.log(data);
+ if(data.responseJSON){
+ var $time = new Date().getTime();
+ form.closest('.pirate_forms_wrap').prepend('
');
+ $('#' + $time).append(data.responseJSON.error);
+ }
+ },
+ complete: function(){
+ ajaxStop( form );
+ }
+ });
+
+ return false;
});
- $button.parent().find('input[type=file]').focus().click();
- });
- jQuery('.pirate-forms-file-upload-input').on('click', function(){
- jQuery(this).parent().find('.pirate-forms-file-upload-button').trigger('click');
- });
- jQuery('.pirate-forms-file-upload-input').on('focus', function(){
- jQuery(this).blur();
- });
-});
\ No newline at end of file
+ }
+
+ function onWindowLoad() {
+ 'use strict';
+ if ( $( '.pirate_forms_wrap' ).length ) {
+ $( '.pirate_forms_wrap' ).each( function () {
+ var formWidth = $( this ).innerWidth();
+ var footerWidth = $( this ).find( '.pirate-forms-footer' ).innerWidth();
+ if ( footerWidth > formWidth ) {
+ $( this ).find( '.contact_submit_wrap, .form_captcha_wrap, .pirateform_wrap_classes_spam_wrap' ).css( {'text-align' : 'left', 'display' : 'block' } );
+ }
+ } );
+ }
+ }
+
+ function ajaxStart(element) {
+ $(element).fadeTo( 'slow', 0.5 );
+ }
+
+ function ajaxStop(element) {
+ $(element).fadeTo( 'fast', 1 );
+ }
+
+})(jQuery, pirateFormsObject);
\ No newline at end of file
diff --git a/readme.md b/readme.md
index c47ace1..ab4ece2 100644
--- a/readme.md
+++ b/readme.md
@@ -2,7 +2,7 @@
**Contributors:** [themeisle](https://profiles.wordpress.org/themeisle), [codeinwp](https://profiles.wordpress.org/codeinwp), [rodicaelena](https://profiles.wordpress.org/rodicaelena), [hardeepasrani](https://profiles.wordpress.org/hardeepasrani), [pirateforms](https://profiles.wordpress.org/pirateforms), [rozroz](https://profiles.wordpress.org/rozroz)
**Tags:** contact form, contact form plugin, forms, smtp, custom form, subscribe form, feedback form, wordpress contact form
**Requires at least:** 3.0
-**Tested up to:** 4.8
+**Tested up to:** 4.9
**Stable tag:** trunk
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
@@ -17,7 +17,7 @@ This is an easy-to-use WordPress contact form with captcha plugin. To create a c
> **Time-saving features available in the FULL version:**
>
> * Create multiple forms
-> * Mailchimp Integration
+> * Mailchimp, GetResponse, Aweber, Sendinblue Integration
> * Custom fields
> * Developer friendly
> * 12 months Support & Updates
@@ -86,6 +86,10 @@ This plugin started as a fork of https://wordpress.org/plugins/proper-contact-fo
## Frequently Asked Questions ##
+
+
+
+
### How I can get support for this contact form plugin ? ###
You can learn more about PirateForms and ask for help by
visiting ThemeIsle website.
@@ -113,7 +117,136 @@ You can follow the full documentation [here](http://docs.themeisle.com/article/4
[http://docs.themeisle.com/article/663-what-actions-and-filters-are-available-in-pirate-forms](http://docs.themeisle.com/article/663-what-actions-and-filters-are-available-in-pirate-forms)
-## Installation ##
+### Emails are not being sent, what can i do ? ###
+ [http://docs.themeisle.com/article/690-emails-are-not-being-sent-what-can-i-do](http://docs.themeisle.com/article/690-emails-are-not-being-sent-what-can-i-do)
+
+ = Why do I not receive any emails? - Pirate Forms =
+ [http://docs.themeisle.com/article/729-why-do-i-not-receive-any-emails-pirate-forms](http://docs.themeisle.com/article/729-why-do-i-not-receive-any-emails-pirate-forms)
+
+ = How to add reCaptcha to a form in Pirate Forms =
+ [http://docs.themeisle.com/article/731-how-to-add-recaptcha-to-a-form-in-pirate-forms](http://docs.themeisle.com/article/731-how-to-add-recaptcha-to-a-form-in-pirate-forms)
+
+ = How to add Dropdown menu in Subject Field in Pirate Forms =
+ [http://docs.themeisle.com/article/725-how-to-add-dropdown-menu-in-subject-field-in-pirate-forms](http://docs.themeisle.com/article/725-how-to-add-dropdown-menu-in-subject-field-in-pirate-forms)
+
+ = How to save contacts in Mailchimp list in Pirate Forms =
+ [http://docs.themeisle.com/article/722-pirate-forms-how-to-save-contacts-in-mailchimp-list](http://docs.themeisle.com/article/722-pirate-forms-how-to-save-contacts-in-mailchimp-list)
+
+ = How to create a Form Widget in Pirate Forms =
+ [http://docs.themeisle.com/article/723-pirate-forms-how-to-create-a-form-widget](http://docs.themeisle.com/article/723-pirate-forms-how-to-create-a-form-widget)
+
+ = How to create a subscription form in Pirate Forms =
+ [http://docs.themeisle.com/article/721-pirate-forms-how-to-create-a-subscription-form](http://docs.themeisle.com/article/721-pirate-forms-how-to-create-a-subscription-form)
+
+ = How to create multiple forms in Pirate Forms =
+ [http://docs.themeisle.com/article/730-how-to-create-multiple-forms-in-pirate-forms](http://docs.themeisle.com/article/730-how-to-create-multiple-forms-in-pirate-forms)
+
+ = How to add multiple upload fields in Pirate Forms =
+ [http://docs.themeisle.com/article/734-how-to-add-multiple-upload-fields-in-pirate-forms](http://docs.themeisle.com/article/734-how-to-add-multiple-upload-fields-in-pirate-forms)
+
+ = How to add a spam trap in a form in Pirate Forms =
+ [http://docs.themeisle.com/article/732-how-to-add-a-spam-trap-in-a-form-in-pirate-forms](http://docs.themeisle.com/article/732-how-to-add-a-spam-trap-in-a-form-in-pirate-forms)
+
+ = How to change default confirmation email content in Pirate Forms =
+ [http://docs.themeisle.com/article/724-how-to-change-default-email-content-in-pirate-forms](http://docs.themeisle.com/article/724-how-to-change-default-email-content-in-pirate-forms)
+
+ = How to add checkbox field in Pirate Forms =
+ [http://docs.themeisle.com/article/733-how-to-add-checkbox-field-in-pirate-forms](http://docs.themeisle.com/article/733-how-to-add-checkbox-field-in-pirate-forms)
+
+ = How can I change HTML of default form in Pirate Forms =
+ [http://docs.themeisle.com/article/745-how-can-i-change-html-of-default-form-in-pirate-forms](http://docs.themeisle.com/article/745-how-can-i-change-html-of-default-form-in-pirate-forms)
+
+ = How to add attributes to form in Pirate Forms =
+ [http://docs.themeisle.com/article/752-how-to-add-attributes-to-form-in-pirate-forms](http://docs.themeisle.com/article/752-how-to-add-attributes-to-form-in-pirate-forms)
+
+ = How to change default email content in Pirate forms =
+ [http://docs.themeisle.com/article/779-how-to-change-default-email-content-in-pirate-forms](http://docs.themeisle.com/article/779-how-to-change-default-email-content-in-pirate-forms)
+
+ = How to change default email content per form in Pirate forms =
+ [http://docs.themeisle.com/article/780-how-to-change-default-email-content-per-form-in-pirate-forms](http://docs.themeisle.com/article/780-how-to-change-default-email-content-per-form-in-pirate-forms)
+
+ = How to install and use extended version of Pirate Forms =
+ [http://docs.themeisle.com/article/787-how-to-install-and-use-extended-version-of-pirate-forms](http://docs.themeisle.com/article/787-how-to-install-and-use-extended-version-of-pirate-forms)
+
+ = Pirate Forms Documentation =
+ [https://docs.themeisle.com/article/436-pirate-forms-documentation](https://docs.themeisle.com/article/436-pirate-forms-documentation)
+
+ = How to Change Pirate Forms Submit Button Color =
+ [https://docs.themeisle.com/article/423-how-to-change-pirate-forms-submit-button-color](https://docs.themeisle.com/article/423-how-to-change-pirate-forms-submit-button-color)
+
+ = How to Center the Send Message button for Pirate Forms =
+ [https://docs.themeisle.com/article/427-how-to-center-the-send-message-button-for-pirate-forms](https://docs.themeisle.com/article/427-how-to-center-the-send-message-button-for-pirate-forms)
+
+ = How you can overwrite the default form template in Pirate Forms =
+ [https://docs.themeisle.com/article/664-how-you-can-overwrite-the-default-form-template-in-pirate-forms](https://docs.themeisle.com/article/664-how-you-can-overwrite-the-default-form-template-in-pirate-forms)
+
+ = How to change font in Pirate Forms =
+ [https://docs.themeisle.com/article/431-how-to-change-font-in-pirate-forms](https://docs.themeisle.com/article/431-how-to-change-font-in-pirate-forms)
+
+ = Why do I not receive any emails? - Pirate Forms =
+ [https://docs.themeisle.com/article/729-why-do-i-not-receive-any-emails---pirate-forms](https://docs.themeisle.com/article/729-why-do-i-not-receive-any-emails---pirate-forms)
+
+ = Emails are not being sent, what can i do ? =
+ [https://docs.themeisle.com/article/690-emails-are-not-being-sent-what-can-i-do](https://docs.themeisle.com/article/690-emails-are-not-being-sent-what-can-i-do)
+
+ = How to add reCaptcha to a form in Pirate Forms =
+ [https://docs.themeisle.com/article/731-how-to-add-recaptcha-to-a-form-in-pirate-forms](https://docs.themeisle.com/article/731-how-to-add-recaptcha-to-a-form-in-pirate-forms)
+
+ = What actions and filters are available in Pirate Forms =
+ [https://docs.themeisle.com/article/663-what-actions-and-filters-are-available-in-pirate-forms](https://docs.themeisle.com/article/663-what-actions-and-filters-are-available-in-pirate-forms)
+
+ = How can I change HTML of default form in Pirate Forms =
+ [https://docs.themeisle.com/article/745-how-can-i-change-html-of-default-form-in-pirate-forms](https://docs.themeisle.com/article/745-how-can-i-change-html-of-default-form-in-pirate-forms)
+
+ = How to add Dropdown menu in Subject Field in Pirate Forms =
+ [https://docs.themeisle.com/article/725-how-to-add-dropdown-menu-in-subject-field-in-pirate-forms](https://docs.themeisle.com/article/725-how-to-add-dropdown-menu-in-subject-field-in-pirate-forms)
+
+ = How to save contacts in Mailchimp list in Pirate Forms =
+ [https://docs.themeisle.com/article/722-how-to-save-contacts-in-mailchimp-list-in-pirate-forms](https://docs.themeisle.com/article/722-how-to-save-contacts-in-mailchimp-list-in-pirate-forms)
+
+ = How to add checkbox field in Pirate Forms =
+ [https://docs.themeisle.com/article/733-how-to-add-checkbox-field-in-pirate-forms](https://docs.themeisle.com/article/733-how-to-add-checkbox-field-in-pirate-forms)
+
+ = How to add a spam trap in a form in Pirate Forms =
+ [https://docs.themeisle.com/article/732-how-to-add-a-spam-trap-in-a-form-in-pirate-forms](https://docs.themeisle.com/article/732-how-to-add-a-spam-trap-in-a-form-in-pirate-forms)
+
+ = How to create multiple forms in Pirate Forms =
+ [https://docs.themeisle.com/article/730-how-to-create-multiple-forms-in-pirate-forms](https://docs.themeisle.com/article/730-how-to-create-multiple-forms-in-pirate-forms)
+
+ = How to create a Form Widget in Pirate Forms =
+ [https://docs.themeisle.com/article/723-how-to-create-a-form-widget-in-pirate-forms](https://docs.themeisle.com/article/723-how-to-create-a-form-widget-in-pirate-forms)
+
+ = How to change default confirmation email content in Pirate Forms =
+ [https://docs.themeisle.com/article/724-how-to-change-default-confirmation-email-content-in-pirate-forms](https://docs.themeisle.com/article/724-how-to-change-default-confirmation-email-content-in-pirate-forms)
+
+ = How to add attributes to form in Pirate Forms =
+ [https://docs.themeisle.com/article/752-how-to-add-attributes-to-form-in-pirate-forms](https://docs.themeisle.com/article/752-how-to-add-attributes-to-form-in-pirate-forms)
+
+ = How to change default email content in Pirate forms =
+ [https://docs.themeisle.com/article/779-how-to-change-default-email-content-in-pirate-forms](https://docs.themeisle.com/article/779-how-to-change-default-email-content-in-pirate-forms)
+
+ = How to add multiple upload fields in Pirate Forms =
+ [https://docs.themeisle.com/article/734-how-to-add-multiple-upload-fields-in-pirate-forms](https://docs.themeisle.com/article/734-how-to-add-multiple-upload-fields-in-pirate-forms)
+
+ = How to create a subscription form in Pirate Forms =
+ [https://docs.themeisle.com/article/721-how-to-create-a-subscription-form-in-pirate-forms](https://docs.themeisle.com/article/721-how-to-create-a-subscription-form-in-pirate-forms)
+
+ = How to change default email content per form in Pirate forms =
+ [https://docs.themeisle.com/article/780-how-to-change-default-email-content-per-form-in-pirate-forms](https://docs.themeisle.com/article/780-how-to-change-default-email-content-per-form-in-pirate-forms)
+
+ = How to install and use extended version of Pirate Forms =
+ [https://docs.themeisle.com/article/787-how-to-install-and-use-extended-version-of-pirate-forms](https://docs.themeisle.com/article/787-how-to-install-and-use-extended-version-of-pirate-forms)
+
+ = How to set a success page on successful form submission =
+ [https://docs.themeisle.com/article/836-how-to-set-a-success-page-on-successful-form-submission](https://docs.themeisle.com/article/836-how-to-set-a-success-page-on-successful-form-submission)
+
+ = Pirate Forms: How to change the default subject of email admin receives =
+ [https://docs.themeisle.com/article/838-pirate-forms-how-to-change-the-default-subject-of-email-admin-receives](https://docs.themeisle.com/article/838-pirate-forms-how-to-change-the-default-subject-of-email-admin-receives)
+
+ = How to send a copy of the sent email to the sender. =
+ [https://docs.themeisle.com/article/837-how-to-send-a-copy-of-the-sent-email-to-the-sender](https://docs.themeisle.com/article/837-how-to-send-a-copy-of-the-sent-email-to-the-sender)
+
+ == Installation ==
Activating the Pirate Contact Form plugin is just like any other plugin. If you've uploaded the plugin package to your server already, skip to step 5 below:
@@ -134,6 +267,74 @@ Activating the Pirate Contact Form plugin is just like any other plugin. If you'
4. Screenshot 4. Enabling SMTP
## Changelog ##
+### 2.4.1 - 2018-05-07 ###
+
+* GDPR compliance
+
+
+### 2.4.0 - 2018-04-02 ###
+
+* Improves compatibility with various themes.
+* Adds support for two new custom fields.
+* Adds filter for custom classes into form fields.
+* Adds visual/text switch to form wyiwyg editor.
+
+
+### 2.3.5 - 2018-03-05 ###
+
+* Fix characters encoding issue in the subject field.
+* Fix issue with spam label with two forms on the page.
+* Allows zip files to be attached in forms.
+* Adds a filter to dynamically change the subject.
+* Adds options to send a copy of the email to the sender.
+
+
+### 2.3.4 - 2018-02-15 ###
+
+* Added missing Loader.gif file
+* Fixed undefined notice
+* Fix submit button leaving form when ReCaptcha is enabled
+
+
+### 2.3.3 - 2018-01-06 ###
+
+* Fix double reCAPTCHA box bug.
+* Fix custom spam trap alignement error.
+
+
+### 2.3.2 - 2017-12-28 ###
+
+* Fix for tooltip admin behavior.
+
+
+### 2.3.1 - 2017-12-28 ###
+
+* Improves layout and compatibility with various themes.
+* Improves form default email format.
+* Fix issues with various special characters in the magic tag fields.
+
+
+### 2.3.0 - 2017-11-27 ###
+
+* Adds email content wysiwyg editor.
+* Improves layout for custom spam trap.
+
+
+### 2.2.5 - 2017-11-16 ###
+
+* Adds compatibility with WordPress 4.9
+* Minor improvement for toggle the password in the admin form fields.
+
+
+### 2.2.4 - 2017-11-13 ###
+
+* Improved assets loading, loading them only they are necessary.
+* Remove hide/show effect for reCaptcha.
+* Add toggle for password field.
+* Add new docs, keeping them in sync with HelpScout .
+* Adds more integration with the pro version.
+
+
### 2.2.3 - 2017-10-24 ###
* Improves compatibility with Hestia theme.
diff --git a/readme.txt b/readme.txt
index c8861f4..2cb0a89 100644
--- a/readme.txt
+++ b/readme.txt
@@ -2,7 +2,7 @@
Contributors: themeisle, codeinwp, rodicaelena, hardeepasrani, pirateforms, rozroz
Tags: contact form, contact form plugin, forms, smtp, custom form, subscribe form, feedback form, wordpress contact form
Requires at least: 3.0
-Tested up to: 4.8
+Tested up to: 4.9
Stable tag: trunk
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -17,7 +17,7 @@ This is an easy-to-use WordPress contact form with captcha plugin. To create a c
> **Time-saving features available in the FULL version:**
>
> * Create multiple forms
-> * Mailchimp Integration
+> * Mailchimp, GetResponse, Aweber, Sendinblue Integration
> * Custom fields
> * Developer friendly
> * 12 months Support & Updates
@@ -86,6 +86,11 @@ This plugin started as a fork of https://wordpress.org/plugins/proper-contact-fo
== Frequently Asked Questions ==
+
+
+
+
+
= How I can get support for this contact form plugin ? =
You can learn more about PirateForms and ask for help by
visiting ThemeIsle website.
@@ -113,7 +118,142 @@ You can follow the full documentation [here](http://docs.themeisle.com/article/4
[http://docs.themeisle.com/article/663-what-actions-and-filters-are-available-in-pirate-forms](http://docs.themeisle.com/article/663-what-actions-and-filters-are-available-in-pirate-forms)
-== Installation ==
+= Emails are not being sent, what can i do ? =
+ [http://docs.themeisle.com/article/690-emails-are-not-being-sent-what-can-i-do](http://docs.themeisle.com/article/690-emails-are-not-being-sent-what-can-i-do)
+
+ = Why do I not receive any emails? - Pirate Forms =
+ [http://docs.themeisle.com/article/729-why-do-i-not-receive-any-emails-pirate-forms](http://docs.themeisle.com/article/729-why-do-i-not-receive-any-emails-pirate-forms)
+
+ = How to add reCaptcha to a form in Pirate Forms =
+ [http://docs.themeisle.com/article/731-how-to-add-recaptcha-to-a-form-in-pirate-forms](http://docs.themeisle.com/article/731-how-to-add-recaptcha-to-a-form-in-pirate-forms)
+
+ = How to add Dropdown menu in Subject Field in Pirate Forms =
+ [http://docs.themeisle.com/article/725-how-to-add-dropdown-menu-in-subject-field-in-pirate-forms](http://docs.themeisle.com/article/725-how-to-add-dropdown-menu-in-subject-field-in-pirate-forms)
+
+ = How to save contacts in Mailchimp list in Pirate Forms =
+ [http://docs.themeisle.com/article/722-pirate-forms-how-to-save-contacts-in-mailchimp-list](http://docs.themeisle.com/article/722-pirate-forms-how-to-save-contacts-in-mailchimp-list)
+
+ = How to create a Form Widget in Pirate Forms =
+ [http://docs.themeisle.com/article/723-pirate-forms-how-to-create-a-form-widget](http://docs.themeisle.com/article/723-pirate-forms-how-to-create-a-form-widget)
+
+ = How to create a subscription form in Pirate Forms =
+ [http://docs.themeisle.com/article/721-pirate-forms-how-to-create-a-subscription-form](http://docs.themeisle.com/article/721-pirate-forms-how-to-create-a-subscription-form)
+
+ = How to create multiple forms in Pirate Forms =
+ [http://docs.themeisle.com/article/730-how-to-create-multiple-forms-in-pirate-forms](http://docs.themeisle.com/article/730-how-to-create-multiple-forms-in-pirate-forms)
+
+ = How to add multiple upload fields in Pirate Forms =
+ [http://docs.themeisle.com/article/734-how-to-add-multiple-upload-fields-in-pirate-forms](http://docs.themeisle.com/article/734-how-to-add-multiple-upload-fields-in-pirate-forms)
+
+ = How to add a spam trap in a form in Pirate Forms =
+ [http://docs.themeisle.com/article/732-how-to-add-a-spam-trap-in-a-form-in-pirate-forms](http://docs.themeisle.com/article/732-how-to-add-a-spam-trap-in-a-form-in-pirate-forms)
+
+ = How to change default confirmation email content in Pirate Forms =
+ [http://docs.themeisle.com/article/724-how-to-change-default-email-content-in-pirate-forms](http://docs.themeisle.com/article/724-how-to-change-default-email-content-in-pirate-forms)
+
+ = How to add checkbox field in Pirate Forms =
+ [http://docs.themeisle.com/article/733-how-to-add-checkbox-field-in-pirate-forms](http://docs.themeisle.com/article/733-how-to-add-checkbox-field-in-pirate-forms)
+
+ = How can I change HTML of default form in Pirate Forms =
+ [http://docs.themeisle.com/article/745-how-can-i-change-html-of-default-form-in-pirate-forms](http://docs.themeisle.com/article/745-how-can-i-change-html-of-default-form-in-pirate-forms)
+
+ = How to add attributes to form in Pirate Forms =
+ [http://docs.themeisle.com/article/752-how-to-add-attributes-to-form-in-pirate-forms](http://docs.themeisle.com/article/752-how-to-add-attributes-to-form-in-pirate-forms)
+
+ = How to change default email content in Pirate forms =
+ [http://docs.themeisle.com/article/779-how-to-change-default-email-content-in-pirate-forms](http://docs.themeisle.com/article/779-how-to-change-default-email-content-in-pirate-forms)
+
+ = How to change default email content per form in Pirate forms =
+ [http://docs.themeisle.com/article/780-how-to-change-default-email-content-per-form-in-pirate-forms](http://docs.themeisle.com/article/780-how-to-change-default-email-content-per-form-in-pirate-forms)
+
+ = How to install and use extended version of Pirate Forms =
+ [http://docs.themeisle.com/article/787-how-to-install-and-use-extended-version-of-pirate-forms](http://docs.themeisle.com/article/787-how-to-install-and-use-extended-version-of-pirate-forms)
+
+ = Pirate Forms Documentation =
+ [https://docs.themeisle.com/article/436-pirate-forms-documentation](https://docs.themeisle.com/article/436-pirate-forms-documentation)
+
+ = How to Change Pirate Forms Submit Button Color =
+ [https://docs.themeisle.com/article/423-how-to-change-pirate-forms-submit-button-color](https://docs.themeisle.com/article/423-how-to-change-pirate-forms-submit-button-color)
+
+ = How to Center the Send Message button for Pirate Forms =
+ [https://docs.themeisle.com/article/427-how-to-center-the-send-message-button-for-pirate-forms](https://docs.themeisle.com/article/427-how-to-center-the-send-message-button-for-pirate-forms)
+
+ = How you can overwrite the default form template in Pirate Forms =
+ [https://docs.themeisle.com/article/664-how-you-can-overwrite-the-default-form-template-in-pirate-forms](https://docs.themeisle.com/article/664-how-you-can-overwrite-the-default-form-template-in-pirate-forms)
+
+ = How to change font in Pirate Forms =
+ [https://docs.themeisle.com/article/431-how-to-change-font-in-pirate-forms](https://docs.themeisle.com/article/431-how-to-change-font-in-pirate-forms)
+
+ = Why do I not receive any emails? - Pirate Forms =
+ [https://docs.themeisle.com/article/729-why-do-i-not-receive-any-emails---pirate-forms](https://docs.themeisle.com/article/729-why-do-i-not-receive-any-emails---pirate-forms)
+
+ = Emails are not being sent, what can i do ? =
+ [https://docs.themeisle.com/article/690-emails-are-not-being-sent-what-can-i-do](https://docs.themeisle.com/article/690-emails-are-not-being-sent-what-can-i-do)
+
+ = How to add reCaptcha to a form in Pirate Forms =
+ [https://docs.themeisle.com/article/731-how-to-add-recaptcha-to-a-form-in-pirate-forms](https://docs.themeisle.com/article/731-how-to-add-recaptcha-to-a-form-in-pirate-forms)
+
+ = What actions and filters are available in Pirate Forms =
+ [https://docs.themeisle.com/article/663-what-actions-and-filters-are-available-in-pirate-forms](https://docs.themeisle.com/article/663-what-actions-and-filters-are-available-in-pirate-forms)
+
+ = How can I change HTML of default form in Pirate Forms =
+ [https://docs.themeisle.com/article/745-how-can-i-change-html-of-default-form-in-pirate-forms](https://docs.themeisle.com/article/745-how-can-i-change-html-of-default-form-in-pirate-forms)
+
+ = How to add Dropdown menu in Subject Field in Pirate Forms =
+ [https://docs.themeisle.com/article/725-how-to-add-dropdown-menu-in-subject-field-in-pirate-forms](https://docs.themeisle.com/article/725-how-to-add-dropdown-menu-in-subject-field-in-pirate-forms)
+
+ = How to save contacts in Mailchimp list in Pirate Forms =
+ [https://docs.themeisle.com/article/722-how-to-save-contacts-in-mailchimp-list-in-pirate-forms](https://docs.themeisle.com/article/722-how-to-save-contacts-in-mailchimp-list-in-pirate-forms)
+
+ = How to add checkbox field in Pirate Forms =
+ [https://docs.themeisle.com/article/733-how-to-add-checkbox-field-in-pirate-forms](https://docs.themeisle.com/article/733-how-to-add-checkbox-field-in-pirate-forms)
+
+ = How to add a spam trap in a form in Pirate Forms =
+ [https://docs.themeisle.com/article/732-how-to-add-a-spam-trap-in-a-form-in-pirate-forms](https://docs.themeisle.com/article/732-how-to-add-a-spam-trap-in-a-form-in-pirate-forms)
+
+ = How to create multiple forms in Pirate Forms =
+ [https://docs.themeisle.com/article/730-how-to-create-multiple-forms-in-pirate-forms](https://docs.themeisle.com/article/730-how-to-create-multiple-forms-in-pirate-forms)
+
+ = How to create a Form Widget in Pirate Forms =
+ [https://docs.themeisle.com/article/723-how-to-create-a-form-widget-in-pirate-forms](https://docs.themeisle.com/article/723-how-to-create-a-form-widget-in-pirate-forms)
+
+ = How to change default confirmation email content in Pirate Forms =
+ [https://docs.themeisle.com/article/724-how-to-change-default-confirmation-email-content-in-pirate-forms](https://docs.themeisle.com/article/724-how-to-change-default-confirmation-email-content-in-pirate-forms)
+
+ = How to add attributes to form in Pirate Forms =
+ [https://docs.themeisle.com/article/752-how-to-add-attributes-to-form-in-pirate-forms](https://docs.themeisle.com/article/752-how-to-add-attributes-to-form-in-pirate-forms)
+
+ = How to change default email content in Pirate forms =
+ [https://docs.themeisle.com/article/779-how-to-change-default-email-content-in-pirate-forms](https://docs.themeisle.com/article/779-how-to-change-default-email-content-in-pirate-forms)
+
+ = How to add multiple upload fields in Pirate Forms =
+ [https://docs.themeisle.com/article/734-how-to-add-multiple-upload-fields-in-pirate-forms](https://docs.themeisle.com/article/734-how-to-add-multiple-upload-fields-in-pirate-forms)
+
+ = How to create a subscription form in Pirate Forms =
+ [https://docs.themeisle.com/article/721-how-to-create-a-subscription-form-in-pirate-forms](https://docs.themeisle.com/article/721-how-to-create-a-subscription-form-in-pirate-forms)
+
+ = How to change default email content per form in Pirate forms =
+ [https://docs.themeisle.com/article/780-how-to-change-default-email-content-per-form-in-pirate-forms](https://docs.themeisle.com/article/780-how-to-change-default-email-content-per-form-in-pirate-forms)
+
+ = How to install and use extended version of Pirate Forms =
+ [https://docs.themeisle.com/article/787-how-to-install-and-use-extended-version-of-pirate-forms](https://docs.themeisle.com/article/787-how-to-install-and-use-extended-version-of-pirate-forms)
+
+ = How to set a success page on successful form submission =
+ [https://docs.themeisle.com/article/836-how-to-set-a-success-page-on-successful-form-submission](https://docs.themeisle.com/article/836-how-to-set-a-success-page-on-successful-form-submission)
+
+ = Pirate Forms: How to change the default subject of email admin receives =
+ [https://docs.themeisle.com/article/838-pirate-forms-how-to-change-the-default-subject-of-email-admin-receives](https://docs.themeisle.com/article/838-pirate-forms-how-to-change-the-default-subject-of-email-admin-receives)
+
+ = How to send a copy of the sent email to the sender. =
+ [https://docs.themeisle.com/article/837-how-to-send-a-copy-of-the-sent-email-to-the-sender](https://docs.themeisle.com/article/837-how-to-send-a-copy-of-the-sent-email-to-the-sender)
+
+ = How to add a multiple choice field in a form =
+ [https://docs.themeisle.com/article/866-how-to-add-a-multiple-choice-field-in-a-form](https://docs.themeisle.com/article/866-how-to-add-a-multiple-choice-field-in-a-form)
+
+ = How to add a select field in a form =
+ [https://docs.themeisle.com/article/867-how-to-add-a-select-field-in-a-form](https://docs.themeisle.com/article/867-how-to-add-a-select-field-in-a-form)
+
+ == Installation ==
Activating the Pirate Contact Form plugin is just like any other plugin. If you've uploaded the plugin package to your server already, skip to step 5 below:
@@ -134,6 +274,74 @@ Activating the Pirate Contact Form plugin is just like any other plugin. If you'
4. Screenshot 4. Enabling SMTP
== Changelog ==
+= 2.4.1 - 2018-05-07 =
+
+* GDPR compliance
+
+
+= 2.4.0 - 2018-04-02 =
+
+* Improves compatibility with various themes.
+* Adds support for two new custom fields.
+* Adds filter for custom classes into form fields.
+* Adds visual/text switch to form wyiwyg editor.
+
+
+= 2.3.5 - 2018-03-05 =
+
+* Fix characters encoding issue in the subject field.
+* Fix issue with spam label with two forms on the page.
+* Allows zip files to be attached in forms.
+* Adds a filter to dynamically change the subject.
+* Adds options to send a copy of the email to the sender.
+
+
+= 2.3.4 - 2018-02-15 =
+
+* Added missing Loader.gif file
+* Fixed undefined notice
+* Fix submit button leaving form when ReCaptcha is enabled
+
+
+= 2.3.3 - 2018-01-06 =
+
+* Fix double reCAPTCHA box bug.
+* Fix custom spam trap alignement error.
+
+
+= 2.3.2 - 2017-12-28 =
+
+* Fix for tooltip admin behavior.
+
+
+= 2.3.1 - 2017-12-28 =
+
+* Improves layout and compatibility with various themes.
+* Improves form default email format.
+* Fix issues with various special characters in the magic tag fields.
+
+
+= 2.3.0 - 2017-11-27 =
+
+* Adds email content wysiwyg editor.
+* Improves layout for custom spam trap.
+
+
+= 2.2.5 - 2017-11-16 =
+
+* Adds compatibility with WordPress 4.9
+* Minor improvement for toggle the password in the admin form fields.
+
+
+= 2.2.4 - 2017-11-13 =
+
+* Improved assets loading, loading them only they are necessary.
+* Remove hide/show effect for reCaptcha.
+* Add toggle for password field.
+* Add new docs, keeping them in sync with HelpScout .
+* Adds more integration with the pro version.
+
+
= 2.2.3 - 2017-10-24 =
* Improves compatibility with Hestia theme.
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 4c9aa14..d90862b 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -9,10 +9,10 @@
$_tests_dir = '/tmp/wordpress-tests-lib';
}
-/************* contactashish13 test environment *************
+/************* For contactashish13 test environment *************
$_tests_dir = 'E:\work\apps\wordpress-dev\tests\phpunit';
$_core_dir = 'E:\work\apps\wordpress-dev\src\\';
-************* contactashish13 test environment *************/
+************* contactashish13 test environment */
/**
* The path to the main file of the plugin to test.
@@ -35,4 +35,4 @@ function _manually_load_plugin() {
global $current_user;
$current_user = new WP_User( 1 );
$current_user->set_role( 'administrator' );
-wp_update_user( array( 'ID' => 1, 'first_name' => 'Admin', 'last_name' => 'User' ) );
\ No newline at end of file
+wp_update_user( array( 'ID' => 1, 'first_name' => 'Admin', 'last_name' => 'User' ) );
diff --git a/tests/test-pirate-forms.php b/tests/test-pirate-forms.php
index 1cb05ae..e07d43d 100644
--- a/tests/test-pirate-forms.php
+++ b/tests/test-pirate-forms.php
@@ -20,118 +20,179 @@ class Test_Pirate_Forms extends WP_UnitTestCase {
* @access public
*/
public function test_wp_mail() {
- do_action('admin_head');
-
- $settings = PirateForms_Util::get_option();
- $this->assertEquals('yes', $settings['pirateformsopt_nonce']);
-
- $settings['pirateformsopt_nonce'] = 'no';
- $settings['pirateformsopt_recaptcha_field'] = 'no';
- $settings['pirateformsopt_store'] = 'yes';
-
- PirateForms_Util::set_option( $settings );
-
- $settings = PirateForms_Util::get_option();
-
- $this->assertEquals('no', $settings['pirateformsopt_nonce']);
- $this->assertEquals('yes', $settings['pirateformsopt_store']);
-
- $_POST = array(
- 'honeypot' => '',
- 'pirate-forms-contact-name' => 'x',
- 'pirate-forms-contact-email' => 'x@x.com',
- 'pirate-forms-contact-subject' => 'x',
- 'pirate-forms-contact-message' => 'x',
- );
- add_action( 'phpmailer_init', array( $this, 'phpmailer_wp_mail' ), 999 );
- do_action('pirate_unittesting_template_redirect');
-
- $posts = get_posts(array(
- 'post_type' => 'pf_contact',
- 'post_author' => 1,
- 'post_status' => 'private',
- 'numberposts' => 1,
- 'fields' => 'ids',
- ));
-
- $this->assertEquals(1, count($posts));
+ do_action( 'admin_head' );
+
+ $settings = PirateForms_Util::get_option();
+ $this->assertEquals( 'yes', $settings['pirateformsopt_nonce'] );
+
+ $settings['pirateformsopt_nonce'] = 'no';
+ $settings['pirateformsopt_recaptcha_field'] = 'no';
+ $settings['pirateformsopt_store'] = 'yes';
+ $settings['pirateformsopt_email_content'] = '
Contact form submission from Test Blog (http://example.org)
Your Name: | {name} |
---|
Your Email: | {email} |
---|
Subject: | {subject} |
---|
Your message: | {message} |
---|
IP address: | {ip} |
---|
IP search: | http://whatismyipaddress.com/ip/{ip} |
---|
Sent from page: | {permalink} |
---|
';
+
+ PirateForms_Util::set_option( $settings );
+
+ $settings = PirateForms_Util::get_option();
+
+ $this->assertEquals( 'no', $settings['pirateformsopt_nonce'] );
+ $this->assertEquals( 'yes', $settings['pirateformsopt_store'] );
+
+ $_POST = array(
+ 'honeypot' => '',
+ 'pirate-forms-contact-name' => 'x',
+ 'pirate-forms-contact-email' => 'x@x.com',
+ 'pirate-forms-contact-subject' => 'x',
+ 'pirate-forms-contact-message' => 'x',
+ );
+ add_action( 'phpmailer_init', array( $this, 'phpmailer_wp_mail' ), 999 );
+ do_action( 'pirate_unittesting_template_redirect' );
+
+ $posts = get_posts(
+ array(
+ 'post_type' => 'pf_contact',
+ 'post_author' => 1,
+ 'post_status' => 'private',
+ 'numberposts' => 1,
+ 'fields' => 'ids',
+ )
+ );
+
+ $this->assertEquals( 1, count( $posts ) );
}
+ /**
+ * Testing confirmation mail.
+ *
+ * @access public
+ */
+ public function test_confirmation_mail() {
+ do_action( 'admin_head' );
+
+ $settings = PirateForms_Util::get_option();
+ $this->assertEquals( 'yes', $settings['pirateformsopt_nonce'] );
+
+ $settings['pirateformsopt_nonce'] = 'no';
+ $settings['pirateformsopt_recaptcha_field'] = 'no';
+ $settings['pirateformsopt_store'] = 'no';
+ $settings['pirateformsopt_confirm_email'] = 'yoyoyoyoyoyo';
+ $settings['pirateformsopt_copy_email'] = 'yes';
+ $settings['pirateformsopt_email_content'] = '
Contact form submission from Test Blog (http://example.org)
Your Name: | {name} |
---|
Your Email: | {email} |
---|
Subject: | {subject} |
---|
Your message: | {message} |
---|
IP address: | {ip} |
---|
IP search: | http://whatismyipaddress.com/ip/{ip} |
---|
Sent from page: | {permalink} |
---|
';
+
+ PirateForms_Util::set_option( $settings );
+
+ $settings = PirateForms_Util::get_option();
+
+ $this->assertEquals( 'no', $settings['pirateformsopt_nonce'] );
+ $this->assertEquals( 'no', $settings['pirateformsopt_store'] );
+ $this->assertEquals( 'yoyoyoyoyoyo', $settings['pirateformsopt_confirm_email'] );
+ $this->assertEquals( 'yes', $settings['pirateformsopt_copy_email'] );
+
+ $_POST = array(
+ 'honeypot' => '',
+ 'pirate-forms-contact-name' => 'x',
+ 'pirate-forms-contact-email' => 'x@x.com',
+ 'pirate-forms-contact-subject' => 'x',
+ 'pirate-forms-contact-message' => 'x',
+ );
+ add_action( 'phpmailer_init', array( $this, 'phpmailer_confirmation_mail' ), 999 );
+ do_action( 'pirate_unittesting_template_redirect' );
+ }
+
/**
* Testing SMTP
*
* @access public
* @dataProvider smptProvider
*/
- public function test_smtp( $host, $port, $user, $pass, $auth) {
- do_action('admin_head');
-
- $settings = PirateForms_Util::get_option();
- $this->assertEquals('yes', $settings['pirateformsopt_nonce']);
- $settings['pirateformsopt_nonce'] = 'no';
- $settings['pirateformsopt_recaptcha_field'] = 'no';
- $settings['pirateformsopt_store'] = 'yes';
- $settings['pirateformsopt_use_smtp'] = 'yes';
- $settings['pirateformsopt_smtp_host'] = $host;
- $settings['pirateformsopt_smtp_port'] = $port;
- $settings['pirateformsopt_use_smtp_authentication'] = $auth ? 'yes' : 'no';
- $settings['pirateformsopt_smtp_username'] = $user;
- $settings['pirateformsopt_smtp_password'] = $pass;
-
- $this->smpt_data = array( 'host' => $host, 'port' => $port, 'user' => $user, 'pass' => $pass, 'auth' => $auth );
-
- PirateForms_Util::set_option( $settings );
-
- $settings = PirateForms_Util::get_option();
-
- $this->assertEquals('no', $settings['pirateformsopt_nonce']);
- $this->assertEquals('yes', $settings['pirateformsopt_store']);
- $this->assertEquals($host, $settings['pirateformsopt_smtp_host']);
-
- $_POST = array(
- 'honeypot' => '',
- 'pirate-forms-contact-name' => 'x',
- 'pirate-forms-contact-email' => 'x@x.com',
- 'pirate-forms-contact-subject' => 'x',
- 'pirate-forms-contact-message' => 'x',
- );
- add_action( 'phpmailer_init', array( $this, 'phpmailer_smtp_mail' ), 999 );
- do_action('pirate_unittesting_template_redirect');
-
- $posts = get_posts(array(
- 'post_type' => 'pf_contact',
- 'post_author' => 1,
- 'post_status' => 'private',
- 'numberposts' => 1,
- 'fields' => 'ids',
- ));
-
- $this->assertEquals(1, count($posts));
+ public function test_smtp( $host, $port, $user, $pass, $auth ) {
+ do_action( 'admin_head' );
+
+ $settings = PirateForms_Util::get_option();
+ $this->assertEquals( 'yes', $settings['pirateformsopt_nonce'] );
+ $settings['pirateformsopt_nonce'] = 'no';
+ $settings['pirateformsopt_recaptcha_field'] = 'no';
+ $settings['pirateformsopt_store'] = 'yes';
+ $settings['pirateformsopt_use_smtp'] = 'yes';
+ $settings['pirateformsopt_smtp_host'] = $host;
+ $settings['pirateformsopt_smtp_port'] = $port;
+ $settings['pirateformsopt_use_smtp_authentication'] = $auth ? 'yes' : 'no';
+ $settings['pirateformsopt_smtp_username'] = $user;
+ $settings['pirateformsopt_smtp_password'] = $pass;
+ $settings['pirateformsopt_email_content'] = '
Contact form submission from Test Blog (http://example.org)
Your Name: | {name} |
---|
Your Email: | {email} |
---|
Subject: | {subject} |
---|
Your message: | {message} |
---|
IP address: | {ip} |
---|
IP search: | http://whatismyipaddress.com/ip/{ip} |
---|
Sent from page: | {permalink} |
---|
';
+
+ $this->smpt_data = array( 'host' => $host, 'port' => $port, 'user' => $user, 'pass' => $pass, 'auth' => $auth );
+
+ PirateForms_Util::set_option( $settings );
+
+ $settings = PirateForms_Util::get_option();
+
+ $this->assertEquals( 'no', $settings['pirateformsopt_nonce'] );
+ $this->assertEquals( 'yes', $settings['pirateformsopt_store'] );
+ $this->assertEquals( $host, $settings['pirateformsopt_smtp_host'] );
+
+ $_POST = array(
+ 'honeypot' => '',
+ 'pirate-forms-contact-name' => 'x',
+ 'pirate-forms-contact-email' => 'x@x.com',
+ 'pirate-forms-contact-subject' => 'x',
+ 'pirate-forms-contact-message' => 'x',
+ );
+ add_action( 'phpmailer_init', array( $this, 'phpmailer_smtp_mail' ), 999 );
+ do_action( 'pirate_unittesting_template_redirect' );
+
+ $posts = get_posts(
+ array(
+ 'post_type' => 'pf_contact',
+ 'post_author' => 1,
+ 'post_status' => 'private',
+ 'numberposts' => 1,
+ 'fields' => 'ids',
+ )
+ );
+
+ $this->assertEquals( 1, count( $posts ) );
}
+ /**
+ * Checking phpmailer for confirmation mail.
+ *
+ * @access public
+ */
+ public function phpmailer_confirmation_mail( $phpmailer ) {
+ // we want to check the email body only for the confirmation email, so we need to check if this is second time 'phpmailer_init' is being fired.
+ if ( 2 === did_action( 'phpmailer_init' ) ) {
+ $this->assertContains( 'yoyoyoyoyoyo', $phpmailer->Body );
+ $this->assertContains( 'Original Email', $phpmailer->Body );
+ $this->assertContains( 'Your Name : x', $phpmailer->Body );
+ $this->assertContains( 'Your Email : x@x.com', $phpmailer->Body );
+ $this->assertContains( 'Subject : x', $phpmailer->Body );
+ $this->assertContains( 'Your message : x', $phpmailer->Body );
+ }
+ }
+
/**
* Checking phpmailer for WP mail
*
* @access public
*/
- public function phpmailer_wp_mail( $phpmailer ) {
- $this->assertEquals('
Contact form submission from Test Blog (http://example.org)
Your Name: | x |
---|
Your Email: | x@x.com |
---|
Subject: | x |
---|
Your message: | x |
---|
IP address: | 127.0.0.1 |
---|
IP search: | http://whatismyipaddress.com/ip/127.0.0.1 |
---|
Sent from page: | |
---|
', $phpmailer->Body);
- }
+ public function phpmailer_wp_mail( $phpmailer ) {
+ $this->assertEquals( '
Contact form submission from Test Blog (http://example.org)
Your Name: | x |
---|
Your Email: | x@x.com |
---|
Subject: | x |
---|
Your message: | x |
---|
IP address: | 127.0.0.1 |
---|
IP search: | http://whatismyipaddress.com/ip/127.0.0.1 |
---|
Sent from page: | |
---|
', $phpmailer->Body );
+ }
/**
* Checking phpmailer for SMTP mail
*
* @access public
*/
- public function phpmailer_smtp_mail( $phpmailer ) {
- $this->assertEquals('
Contact form submission from Test Blog (http://example.org)
Your Name: | x |
---|
Your Email: | x@x.com |
---|
Subject: | x |
---|
Your message: | x |
---|
IP address: | 127.0.0.1 |
---|
IP search: | http://whatismyipaddress.com/ip/127.0.0.1 |
---|
Sent from page: | |
---|
', $phpmailer->Body);
- $this->assertEquals($this->smpt_data['host'], $phpmailer->Host);
- $this->assertEquals($this->smpt_data['port'], $phpmailer->Port);
- $this->assertEquals($this->smpt_data['user'], $phpmailer->Username);
- $this->assertEquals($this->smpt_data['pass'], $phpmailer->Password);
- }
+ public function phpmailer_smtp_mail( $phpmailer ) {
+ $this->assertEquals( '
Contact form submission from Test Blog (http://example.org)
Your Name: | x |
---|
Your Email: | x@x.com |
---|
Subject: | x |
---|
Your message: | x |
---|
IP address: | 127.0.0.1 |
---|
IP search: | http://whatismyipaddress.com/ip/127.0.0.1 |
---|
Sent from page: | |
---|
', $phpmailer->Body );
+ $this->assertEquals( $this->smpt_data['host'], $phpmailer->Host );
+ $this->assertEquals( $this->smpt_data['port'], $phpmailer->Port );
+ $this->assertEquals( $this->smpt_data['user'], $phpmailer->Username );
+ $this->assertEquals( $this->smpt_data['pass'], $phpmailer->Password );
+ }
/**
* Provide the SMTP data
diff --git a/webpack.config.js b/webpack.config.js
new file mode 100644
index 0000000..82a7a8e
--- /dev/null
+++ b/webpack.config.js
@@ -0,0 +1,29 @@
+var webpack = require( 'webpack' ),
+ NODE_ENV = process.env.NODE_ENV || 'development',
+ webpackConfig = {
+ entry: './gutenberg/js/block.js',
+ output: {
+ path: __dirname,
+ filename: './gutenberg/js/block.build.js',
+ },
+ module: {
+ loaders: [
+ {
+ test: /.js$/,
+ loader: 'babel-loader',
+ exclude: /node_modules/,
+ },
+ ],
+ },
+ plugins: [
+ new webpack.DefinePlugin( {
+ 'process.env.NODE_ENV': JSON.stringify( NODE_ENV )
+ } ),
+ ]
+};
+
+if ( 'production' === NODE_ENV ) {
+ webpackConfig.plugins.push( new webpack.optimize.UglifyJsPlugin() );
+}
+
+module.exports = webpackConfig;
\ No newline at end of file