Wordpress Post从前端格式化问题

时间:2012-11-11 16:14:50

标签: php wordpress post permissions admin

* *编辑

现在好了,我修好了!添加了

    add_action('init', 'kses_init');

我知道这是不安全的,但表格确实有很多验证,所以我认为应该没问题。如果有人能想到更好的方法,我会很乐意知道它因为我对编码和PHP并不十分了解,我所知道的一切都是通过Google loool自学的。

由于


基本上,使用这个网站和大量的教程,我设法为我的网站制作了一个“Post From Front Ent”表格。如果您以管理员身份登录,但如果您已登录任何其他帐户,则会分解代码并从帖子中删除所有HTML。

我绝对不知道出了什么问题,我已经尝试将帖子设置为自动归因于管理员但是没有改进。

当我在普通帐户中发帖时,帖子如下所示:http://i.stack.imgur.com/xwbIK.png

如果你们中的任何人能够纠正这个问题,我会非常感激!!

如果您需要查看代码,请告诉我并将其粘贴到!!

好的,经过mod的一些建议后,我认为代码中的一些内容就是帖子内容,它会从我放入的代码中删除所有HTML。我在帖子中的代码如下,第一位是字符串的定义,第二位是后期脚本:

    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. ' &ndash; ' .$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中的所有代码,'style'和'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>';

1 个答案:

答案 0 :(得分:0)

修改

现在好了,我修好了!加入

add_action('init', 'kses_init');

我知道这是不安全的,但表单确实有很多验证,所以我认为应该没问题。如果有人能想出更好的方法,我很乐意知道。

相关问题