function wpcf7_akismet_submitted_params() { $params = array('author' => '', 'author_email' => '', 'author_url' => ''); $content = ''; $fes = wpcf7_scan_shortcode(); foreach ($fes as $fe) { if (!isset($fe['name']) || !isset($_POST[$fe['name']])) { continue; } $value = $_POST[$fe['name']]; if (is_array($value)) { $value = implode(', ', wpcf7_array_flatten($value)); } $value = trim($value); $options = (array) $fe['options']; if (preg_grep('%^akismet:author$%', $options)) { $params['author'] = trim($params['author'] . ' ' . $value); } elseif (preg_grep('%^akismet:author_email$%', $options)) { if ('' == $params['author_email']) { $params['author_email'] = $value; } } elseif (preg_grep('%^akismet:author_url$%', $options)) { if ('' == $params['author_url']) { $params['author_url'] = $value; } } $content = trim($content . "\n\n" . $value); } $params = array_filter($params); if (!$params) { return false; } $params['content'] = $content; return $params; }
function wpcf7_flat_join($input) { $input = wpcf7_array_flatten($input); $output = array(); foreach ((array) $input as $value) { $output[] = trim((string) $value); } return implode(', ', $output); }
function wpcf7_akismet_submitted_params() { $params = array('author' => '', 'author_email' => '', 'author_url' => '', 'content' => ''); $has_akismet_option = false; foreach ((array) $_POST as $key => $val) { if ('_wpcf7' == substr($key, 0, 6) || '_wpnonce' == $key) { continue; } if (is_array($val)) { $val = implode(', ', wpcf7_array_flatten($val)); } $val = trim($val); if (0 == strlen($val)) { continue; } if ($tags = wpcf7_scan_shortcode(array('name' => $key))) { $tag = $tags[0]; $tag = new WPCF7_Shortcode($tag); $akismet = $tag->get_option('akismet', '(author|author_email|author_url)', true); if ($akismet) { $has_akismet_option = true; if ('author' == $akismet) { $params[$akismet] = trim($params[$akismet] . ' ' . $val); } elseif ('' == $params[$akismet]) { $params[$akismet] = $val; } } } $params['content'] .= "\n\n" . $val; } if (!$has_akismet_option) { return false; } $params['content'] = trim($params['content']); return $params; }
public function save() { $props = $this->get_properties(); $post_content = implode("\n", wpcf7_array_flatten($props)); if ($this->initial()) { $post_id = wp_insert_post(array('post_type' => self::post_type, 'post_status' => 'publish', 'post_title' => $this->title, 'post_content' => trim($post_content))); } else { $post_id = wp_update_post(array('ID' => (int) $this->id, 'post_status' => 'publish', 'post_title' => $this->title, 'post_content' => trim($post_content))); } if ($post_id) { foreach ($props as $prop => $value) { update_post_meta($post_id, '_' . $prop, wpcf7_normalize_newline_deep($value)); } if (wpcf7_is_valid_locale($this->locale)) { update_post_meta($post_id, '_locale', $this->locale); } if ($this->initial()) { $this->id = $post_id; do_action('wpcf7_after_create', $this); } else { do_action('wpcf7_after_update', $this); } do_action('wpcf7_after_save', $this); } return $post_id; }
private function blacklist_check() { $target = wpcf7_array_flatten($this->posted_data); $target[] = $this->get_meta('remote_ip'); $target[] = $this->get_meta('user_agent'); $target = implode("\n", $target); return wpcf7_blacklist_check($target); }
function wpcf7_array_flatten($input) { if (!is_array($input)) { return array($input); } $output = array(); foreach ($input as $value) { $output = array_merge($output, wpcf7_array_flatten($value)); } return $output; }
private function blacklist_check() { $target = wpcf7_array_flatten($this->posted_data); $target[] = $_SERVER['REMOTE_ADDR']; $target[] = $_SERVER['HTTP_USER_AGENT']; $target = implode("\n", $target); return wpcf7_blacklist_check($target); }