'; echo '
'; if (empty($acfName)) { echo '
' . 'Name'; } else { echo '
' . $acfName; } echo '' . '
'; if (empty($acfEmail)) { echo '
' . 'Email'; } else { echo '
' . $acfEmail; } echo '' . '
'; echo '
'; if (empty($acfEmail)) { echo '
' . 'Subject' . '
'; } else { echo '
' . $acfSubject . '
'; } echo '
' . '' . '
'; if (empty($acfMessage)) { echo '
' . 'Message' . '
'; } else { echo '
' . $acfMessage . '
'; } echo ''; echo '
' . '

' . '
'; echo ''; echo ''; } /* Sanitize and check similarity with custom posts. */ function acfl_similair() { if ( isset( $_POST['acfl-submitted'])) { $name = sanitize_text_field( $_POST["acfl-name-form"] ); $email = sanitize_email( $_POST["acfl-email-form"] ); $subject = sanitize_text_field( $_POST["acfl-subject-form"] ); $message = esc_textarea( $_POST["acfl-message-form"] ); $to = get_option( 'acf_admin_email' ); $headers = "From: $name <$email>" . "\r\n"; $answers_args = array( 'posts_per_page' => -1, 'orderby'=> 'date', 'order'=> 'DESC', 'post_type'=> 'answer', 'post_status'=> 'publish', 'suppress_filters' => true ); echo '
'; echo '

' . get_option('acf_similair_title') . '

'; echo '

' . get_option('acf_similair_desc') . '

'; echo '
'; $posts_answers_gallery = get_posts( $answers_args ); foreach($posts_answers_gallery as $rows){ $post_titles = $rows->post_title; $post_content = $rows->post_content; similar_text($post_titles, $message, $percent); if ($percent > 90) { echo '
' . '
' . '

' . $post_titles . '

' . '
' . '

' . $post_content . '

' . '
' . '
' . '
'; } elseif ($percent > 75) { echo '
' . '
' . '

' . $post_titles . '

' . '
' . '

' . $post_content . '

' . '
' . '
' . '
'; } elseif ($percent > 50) { echo '
' . '
' . '

' . $post_titles . '

' . '
' . '

' . $post_content . '

' . '
' . '
' . '
'; } if ($percent > 50) { $shown_posts = 0; $shown_posts++; } } if ($shown_posts >= 1) { wp_enqueue_style( 'acflHide' ); echo '
'; echo ''; echo ''; echo '
'; } elseif ( wp_mail( $to, $subject, $message, $headers ) ) { echo '
' . get_option( 'acf_success_message' ) . '
'; } else { echo '
' . get_option( 'acf_error_message' ) . '
'; } } } /* If no similair custom post found.. send email. */ function acfl_deliver_mail() { if ( isset( $_POST['acfl-submit-now'])) { $name = sanitize_text_field( $_POST["acfl-name-form"] ); $email = sanitize_email( $_POST["acfl-email-form"] ); $subject = sanitize_text_field( $_POST["acfl-subject-form"] ); $message = esc_textarea( $_POST["acfl-message-form"] ); // get the blog administrator's email address $to = get_option( 'acf_admin_email' ); $headers = "From: $name <$email>" . "\r\n"; // If email has been process for sending, display a success message if ( wp_mail( $to, $subject, $message, $headers ) ) { echo '
' . get_option( 'acf_success_message' ) . '
'; } else { echo '
' . get_option( 'acf_error_message' ) . '
'; } } } ?>