芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/www/wp-content/plugins/fluentform/app/Services/Integrations/Slack/Slack.php
$input) { if (empty($formData[$name])) { continue; } if ('tabular_grid' == ArrayHelper::get($input, 'element', '')) { $formData[$name] = Helper::getTabularGridFormatValue($formData[$name], $input, '
', ', ', 'markdown'); } } $formData = FormDataParser::parseData((object) $formData, $inputs, $form->id); $slackTitle = ArrayHelper::get($settings, 'textTitle'); if ('' === $slackTitle) { $title = 'New submission on ' . $form->title; } else { $title = $slackTitle; } $footerText = ArrayHelper::get($settings, 'footerText'); if ($footerText === '') { $footerText = "fluentform"; } $fields = []; foreach ($formData as $attribute => $value) { $value = str_replace('
', "\n", $value); $value = str_replace('&', '&', $value); $value = str_replace('<', '<', $value); $value = str_replace('>', '>', $value); if (! isset($labels[$attribute]) || empty($value)) { continue; } $fields[] = [ 'title' => $labels[$attribute], 'value' => $value, 'short' => false, ]; } $slackHook = ArrayHelper::get($settings, 'webhook'); $titleLink = admin_url( 'admin.php?page=fluent_forms&form_id=' . $form->id . '&route=entries#/entries/' . $entry->id ); $body = [ 'payload' => json_encode([ 'attachments' => [ [ 'color' => '#0078ff', 'fallback' => $title, 'title' => $title, 'title_link' => $titleLink, 'fields' => $fields, 'footer' => $footerText, 'ts' => round(microtime(true) * 1000) ] ] ]) ]; $result = wp_remote_post($slackHook, [ 'method' => 'POST', 'timeout' => 30, 'redirection' => 5, 'httpversion' => '1.0', 'headers' => [], 'body' => $body, 'cookies' => [], ]); if (is_wp_error($result)) { $status = 'failed'; $message = $result->get_error_message(); } else { $message = $result['response']; $status = 200 == $result['response']['code'] ? 'success' : 'failed'; } if ('failed' == $status) { do_action('fluentform/integration_action_result', $feed, 'failed', $message); } else { do_action('fluentform/integration_action_result', $feed, 'success', 'Submission notification has been successfully delivered to slack channel'); } return [ 'status' => $status, 'message' => $message, ]; } }