* *编辑
现在好了,我修好了!添加
add_action('init', 'kses_init');
我知道这是不安全的,但表格确实有很多验证,所以我认为应该没问题。如果有人能想到更好的方法,我很想知道它,因为我是对编码和 PHP 不太了解,我所知道的一切都是通过 Google loool 自学的。
谢谢
基本上,使用这个网站和它的大量教程,我设法为我的网站制作了一个“从 Front Ent 发布”表格。如果您以管理员身份登录,它可以完美运行,但如果您以任何其他帐户登录,它会分解代码并从帖子中删除所有 HTML。
我完全不知道出了什么问题,我尝试将帖子设置为自动归因于管理员,但这并没有改善任何事情。
当我在普通帐户中发帖时,帖子看起来像这样:http: //i.stack.imgur.com/xwbIK.png
如果你们中的任何人都可以纠正这个问题,我将非常感激!
如果您需要查看代码,请告诉我并将其粘贴进去!!
好的,在某个 mod 的一些建议之后,我认为磨损的代码部分是帖子内容,它从我输入的代码中删除了所有 HTML。我为帖子提供的代码如下,第一个bit 是字符串的定义,第二个是 post 脚本:
function simple_fep_add_post(){
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'post' ){
if ( !is_user_logged_in() )
return;
global $current_user;
$user_id = $current_user->ID;
$post_title = $_POST['post-title'];
$post_artist = $_POST['video-artist'];
$anti_spam = $_POST['anti-spam'];
$artist_twitter = $_POST['artist-twitter'];
$post_cat = array(intval($_POST['post-category']));
$twitter_trimmed = ltrim($artist_twitter, "@.");
$video_type = $_POST['video-type'];
$fv_video = $_POST['fv_video'];
$post_content = $_POST['posttext'];
$tags = $_POST['tags'];
$headers = get_headers('http://gdata.youtube.com/feeds/api/videos/' . $fv_video);
$user_infos = 'http://api.twitter.com/1/users/show.xml?screen_name='.$twitter_trimmed;
$content = '<style>.video-box{ border:1px solid #efefef;height:100%;padding:15px;background:#fff;}</style><div class="video-box"><iframe width="595" height="350" src="http://www.youtube.com/embed/'.$fv_video.'?rel=0" frameborder="0" allowfullscreen></iframe></div><style>.desc-box{ border:1px solid #efefef;height:100%;margin-top:10px;margin-bottom:10px;padding:15px;background:#fff;}</style><div class="desc-box"><h4>description</h4>'.$post_content.'</div>';
这一点是我定义错误消息等的地方 - 我很确定这里没有错
if (count($error_array) == 0){
remove_filter('pre_user_description', 'wp_filter_kses');
function my_change_author( $data , $postarr )
{
$data['post_author'] = 2;
return $data;
}
add_filter('wp_insert_post_data' , 'my_change_author' , '99', 2);
$new_post = array(
'post_author' => '2',
'post_title' => $post_artist. ' – ' .$post_title. ' [Guest Post] ['.$video_type.' Video] [@'.$twitter_trimmed.']',
'post_type' => 'post',
'post_content' => $content,
'tags_input' => $tags,
'post_category' => $post_cat,
'post_status' => 'publish'
);
//SAVE THE POST
$pid = wp_insert_post($new_post);
//SET OUR TAGS UP PROPERLY
wp_set_post_tags($pid, $_POST['tags']);
global $notice_array;
$notice_array = array();
$notice_array[] = "Thank you for posting. Your post is now live. Go
to the homepage to view it!";
add_action('simple-fep-notice', 'simple_fep_notices');
} else {
add_action('simple-fep-notice', 'simple_fep_errors');
}
}
}
add_action('init','simple_fep_add_post');
//POST THE POST YO
do_action('wp_insert_post', 'wp_insert_post'); "
代码到此结束
编辑*
在进行了更多修改之后,我转向了 WP 从帖子 IE 中剥离所有代码的问题,“样式”和“div”标签与视频嵌入代码一起被剥离......有没有办法阻止 WP 格式化输入了什么?
*再次编辑***
这是经过更多修改后的字符串定义,我已经设法让网站现在发布样式,它只是不断从帖子中剥离 Iframe……有什么想法吗?
global $user_ID;
$post_title = $_POST['post-title'];
$post_artist = $_POST['video-artist'];
$anti_spam = $_POST['anti-spam'];
$artist_twitter = $_POST['artist-twitter'];
$post_cat = array(intval($_POST['post-category']));
$twitter_trimmed = ltrim($artist_twitter, "@.");
$video_type = $_POST['video-type'];
$fv_video = $_POST['fv_video'];
$post_content = $_POST['posttext'];
$tags = $_POST['tags'];
$headers = get_headers('http://gdata.youtube.com/feeds/api/videos/' . $fv_video);
$user_infos = 'http://api.twitter.com/1/users/show.xml?screen_name='.$twitter_trimmed;
$content = '<div style="border:1px solid #efefef;height:100%;padding:15px;background:#fff;"><iframe width="595" height="350" src="http://www.youtube.com/embed/'.$fv_video.'?rel=0" frameborder="0" allowfullscreen></iframe></div><div style="border:1px solid #efefef;height:100%;margin-top:10px;margin-bottom:10px;padding:15px;background:#fff;"><h4>description</h4>'.$post_content.'</div>';