? esc_url_raw( wp_unslash( get_option('wpr_referrer_'. $_POST['wpr_form_id']) ) ) : '', // phpcs:ignore WordPress.Security.NonceVerification.Missing 'value' => get_option('wpr_referrer_'. $_POST['wpr_form_id']) ? get_option('wpr_referrer_'. $_POST['wpr_form_id']) : '', // phpcs:ignore WordPress.Security.NonceVerification.Missing ]; break; case 'page_title': $meta_fields['page_title'] = [ 'title' => esc_html__( 'Page Title', 'wpr-addons' ), // 'value' => get_option('wpr_referrer_title_'. $_POST['wpr_form_id']) ? sanitize_text_field( wp_unslash( get_option('wpr_referrer_title_'. $_POST['wpr_form_id']) ) ) : '', // phpcs:ignore WordPress.Security.NonceVerification.Missing 'value' => get_option('wpr_referrer_title_'. $_POST['wpr_form_id']) ? get_option('wpr_referrer_title_'. $_POST['wpr_form_id']) : '', // phpcs:ignore WordPress.Security.NonceVerification.Missing ]; break; case 'user_agent': $meta_fields['user_agent'] = [ 'title' => esc_html__( 'User Agent', 'wpr-addons' ), 'value' => isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_textarea_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : '', ]; break; case 'remote_ip': $meta_fields['remote_ip'] = [ 'title' => esc_html__( 'Remote IP', 'wpr-addons' ), 'value' => Utilities::get_client_ip(), ]; break; case 'credit': $meta_fields['credit'] = [ 'title' => esc_html__( 'Powered by', 'wpr-addons' ), 'value' => esc_html__( 'Royal Addons', 'wpr-addons' ), // is it necessary ? ]; break; } } $email_meta = []; foreach( $meta_fields as $key => $value ) { $email_meta[] = $value['title'] . ': ' . $value['value']; } $to = get_option('wpr_email_to_'. $_POST['wpr_form_id']); $to = preg_replace_callback( '/\[id="(\w+)"\]/', function ($matches) { return $this->get_field_value($matches[1]); }, $to ); $subject = get_option('wpr_email_subject_'. $_POST['wpr_form_id']); $subject = preg_replace_callback( '/\[id="(\w+)"\]/', function ($matches) { return $this->get_field_value($matches[1]); }, $subject ); if ( $processed_message ) { $message_body[] = $processed_message; } // Prepare the message body with correct line breaks if ($content_type === 'html') { // Replace all instances of \n with
in each message body item foreach ($message_body as &$item) { $item = nl2br($item); } unset($item); // Break the reference with the last element } $body = implode($line_break, $message_body) . $line_break . '-----' . $line_break . implode($line_break, $email_meta); $cc_header = ''; if ( !empty( get_option('wpr_cc_header_'. $_POST['wpr_form_id']) ) ) { $cc_header = 'Cc: ' . get_option('wpr_cc_header_'. $_POST['wpr_form_id']); $cc_header = preg_replace_callback( '/\[id="(\w+)"\]/', function ($matches) { return $this->get_field_value($matches[1]); }, $cc_header ); } $bcc_header = ''; if ( !empty( get_option('wpr_bcc_header_'. $_POST['wpr_form_id']) ) ) { $bcc_header = 'Bcc: ' . get_option('wpr_bcc_header_'. $_POST['wpr_form_id']); $bcc_header = preg_replace_callback( '/\[id="(\w+)"\]/', function ($matches) { return $this->get_field_value($matches[1]); }, $bcc_header ); } if ( !empty( get_option('wpr_reply_to_'. $_POST['wpr_form_id']) ) && !empty(get_option('wpr_email_from_name_'. $_POST['wpr_form_id'])) && !empty(get_option('wpr_email_from_'. $_POST['wpr_form_id'])) ) { preg_match_all('/id="([^"]+)"/', get_option('wpr_reply_to_'. $_POST['wpr_form_id']), $matche); $reply_to_field_id = $matche[1]; preg_match_all('/id="([^"]+)"/', get_option('wpr_email_from_name_'. $_POST['wpr_form_id']), $matche); $email_from_name_field_id = $matche[1]; preg_match_all('/id="([^"]+)"/', get_option('wpr_email_from_'. $_POST['wpr_form_id']), $matche); $email_from_field_id = $matche[1]; foreach ( $_POST['form_content'] as $key => $value ) { $key_parts = explode('-', $key); $last_part = end($key_parts); if (in_array($last_part, $reply_to_field_id)) { $reply_to_address = $value[1]; } if (in_array($last_part, $email_from_name_field_id)) { $email_from_name = $value[1]; } if (in_array($last_part, $email_from_field_id)) { $email_from_mail = $value[1]; } } if ( !isset($reply_to_address) || empty($reply_to_address) ) { $reply_to_address = get_option('wpr_reply_to_'. $_POST['wpr_form_id']); } if ( !isset($email_from_name) || empty($email_from_name) ) { $email_from_name = get_option('wpr_email_from_name_'. $_POST['wpr_form_id']); } if ( !isset($email_from_mail) || empty($email_from_mail) ) { $email_from_mail = get_option('wpr_email_from_'. $_POST['wpr_form_id']); } $reply_to = 'Reply-To: ' . $reply_to_address; } $email_from = sprintf( 'From: %s <%s>' . "\r\n", $email_from_name, $email_from_mail ); $headers = array('Content-Type: text/'. $content_type .'; charset=UTF-8', $email_from, $cc_header, $bcc_header, $reply_to); // Send email using wp_mail() function $sent = wp_mail( $to, $subject, $body, $headers); if ( $sent ) { wp_send_json_success(array( 'action' => 'wpr_form_builder_email', 'message' => esc_html__('Message sent successfully', 'wpr-addons'), 'status' => 'success', 'details' => json_encode($message_body) )); } else { wp_send_json_error(array( 'action' => 'wpr_form_builder_email', 'message' => esc_html__('Message could not be sent', 'wpr-addons'), 'status' => 'error', 'details' => json_encode($message_body) )); } } public function get_field_value($field_id) { foreach ($_POST['form_content'] as $key => $field) { $key_parts = explode('-', $key); $last_part = end($key_parts); if ($last_part === $field_id) { return $field[1]; } } return ''; // Return an empty string if the field id is not found } } new WPR_Send_Email();
Fatal error: Trait "Yoast\WP\SEO\Conditionals\Traits\Admin_Conditional_Trait" not found in /htdocs/wp-content/plugins/wordpress-seo/src/llms-txt/user-interface/enable-llms-txt-option-watcher.php on line 14