I am trying to dynamicly add some content post (also containing some js), but the javascript part is filter out. I thought by using wp_set_current_user the js would be included.
This is my main function which generate the post
function mydomain_which_page2($atts) {
extract( shortcode_atts( array(
'temp_title' => 'something'
), $atts ) );
//post exists?
if( wp_exist_post_by_title( $temp_title ) ) {
$redirect_title = sanitize_title( $temp_title);
header('Location:' . $redirect_title);
exit();
} else {
// post does not exist
wp_set_current_user(NULL, 'Test user');
//GET THE MAPS
$output = getIncludeContent('myotherdomain.com/generate.php');
//SAVE AS WP POSTS
mydomain_add_post($temp_title,$output);
//REDIRECT
$redirect_title = sanitize_title( $temp_title);
header('Location:' . $redirect_title);
exit();
}
}
directly going to myotherdomain.com/generate.php will output the js in source code also $output will show the source code with js. and add_post function
function add_post($title, $content){
// Create post object wp_strip_all_tags
//$content = strip_tags($content);
$my_post = array(
'post_title' => $title,
'post_content' => $content,
'post_name' => sanitize_title($title),
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array(1)
);
// Insert the post into the database
wp_insert_post( $my_post );
}
Any tips, suggestions?
regards