WP stripping out code
-
Hi
I am using some php in my functions.php with a form on another page which creates posts on my wordpress site, when using this php form on a non-wordpress site without the post creation feature, it functions perfectly however when using on my wordpress site it appears to strip out the site name in the [tab:sitename] and just leaves [tab:].
Any ideas?
This is the code for functions.php:
$formatted = ""; $groups = array(); $first = true; if(isset($_POST["input"])) { $iframes = split("\n", $_POST["input"]); foreach($iframes as $iframe) { $iframe = trim($iframe); if($iframe == "") { continue; } if(stripos($iframe, "iframe") === false) { if(!$first) { $formatted .= "[tab:END]\n"; array_push($groups, $formatted); $formatted = ""; } $formatted .= $iframe . "\n"; $first = false; continue; } preg_match_all('/src="([^"]*)"/i', $iframe, $matches); $site_name = $matches[1][0]; $site_name = parse_url($site_name); $site_name = $site_name["host"]; $site_name = split("\.", $site_name); $site_name = $site_name[0] == "www" ? $site_name[1] : $site_name[0]; $formatted .= "[tab:" . $site_name . "]"; $formatted .= $iframe; $formatted .= "\n"; } $formatted .= "[tab:END]\n"; array_push($groups, $formatted); foreach($groups as $group) { $title = split("\n", $group); $title = $title[0]; $title = split("/", $title); $title = ucwords(str_replace("-", " ", $title[3])); $post = array( "post_content" => $group, "post_title" => $title, "post_status" => "publish", "filter" => true ); wp_insert_post($post, $wp_error); } }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘WP stripping out code’ is closed to new replies.