当前位置: 首页>>代码示例>>PHP>>正文


PHP kses_remove_filters函数代码示例

本文整理汇总了PHP中kses_remove_filters函数的典型用法代码示例。如果您正苦于以下问题:PHP kses_remove_filters函数的具体用法?PHP kses_remove_filters怎么用?PHP kses_remove_filters使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了kses_remove_filters函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cfNoKsesOnImport

function cfNoKsesOnImport()
{
    //Only if administrator:
    if (current_user_can('manage_options')) {
        kses_remove_filters();
    }
}
开发者ID:programmin1,项目名称:wp-no-kses-on-import,代码行数:7,代码来源:cf-no-kses-on-import.php

示例2: allow_unfiltered

 public function allow_unfiltered($value)
 {
     global $post;
     if (isset($post->post_type) && $this->cpt->post_type == $post->post_type && current_user_can('edit_posts')) {
         kses_remove_filters();
     }
     return $value;
 }
开发者ID:JPry,项目名称:Code-Snippets-CPT,代码行数:8,代码来源:dsgnwrks-code-snippets-cpt.php

示例3: unfilter_check

 function unfilter_check($allcaps, $caps, $args)
 {
     global $psts;
     if (is_super_admin()) {
         return;
     }
     if (is_pro_site(false, $psts->get_setting('uh_level', 1)) || $this->ads_unfilter()) {
         $allcaps['unfiltered_html'] = true;
         kses_remove_filters();
     } else {
         unset($allcaps['unfiltered_html']);
     }
     return $allcaps;
 }
开发者ID:vilmark,项目名称:vilmark_main,代码行数:14,代码来源:unfiltered-html.php

示例4: ajax_comment

function ajax_comment()
{
    global $wpdb;
    $comment_post_ID = isset($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : 0;
    $post = get_post($comment_post_ID);
    if (empty($post->comment_status)) {
        do_action('comment_id_not_found', $comment_post_ID);
        ajax_comment_err(__('Invalid comment status.'));
    }
    $status = get_post_status($post);
    $status_obj = get_post_status_object($status);
    if (!comments_open($comment_post_ID)) {
        do_action('comment_closed', $comment_post_ID);
        ajax_comment_err(__('Sorry, comments are closed for this item.'));
    } elseif ('trash' == $status) {
        do_action('comment_on_trash', $comment_post_ID);
        ajax_comment_err(__('Invalid comment status.'));
    } elseif (!$status_obj->public && !$status_obj->private) {
        do_action('comment_on_draft', $comment_post_ID);
        ajax_comment_err(__('Invalid comment status.'));
    } elseif (post_password_required($comment_post_ID)) {
        do_action('comment_on_password_protected', $comment_post_ID);
        ajax_comment_err(__('Password Protected'));
    } else {
        do_action('pre_comment_on_post', $comment_post_ID);
    }
    $comment_author = isset($_POST['author']) ? trim(strip_tags($_POST['author'])) : null;
    $comment_author_email = isset($_POST['email']) ? trim($_POST['email']) : null;
    $comment_author_url = isset($_POST['url']) ? trim($_POST['url']) : null;
    $comment_content = isset($_POST['comment']) ? trim($_POST['comment']) : null;
    $user = wp_get_current_user();
    if ($user->exists()) {
        if (empty($user->display_name)) {
            $user->display_name = $user->user_login;
        }
        $comment_author = $wpdb->escape($user->display_name);
        $comment_author_email = $wpdb->escape($user->user_email);
        $comment_author_url = $wpdb->escape($user->user_url);
        $user_ID = $wpdb->escape($user->ID);
        if (current_user_can('unfiltered_html')) {
            if (wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment']) {
                kses_remove_filters();
                kses_init_filters();
            }
        }
    } else {
        if (get_option('comment_registration') || 'private' == $status) {
            ajax_comment_err('对不起,您必须登录后才能进行评论');
        }
    }
    $comment_type = '';
    if (get_option('require_name_email') && !$user->exists()) {
        if (6 > strlen($comment_author_email) || '' == $comment_author) {
            ajax_comment_err('错误: 请填写如下信息 (姓名, 电子邮件)');
        } elseif (!is_email($comment_author_email)) {
            ajax_comment_err('错误: 请输入正确的邮件地址');
        }
    }
    if ('' == $comment_content) {
        ajax_comment_err('请输入回复内容');
    }
    $dupe = "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = '{$comment_post_ID}' AND ( comment_author = '{$comment_author}' ";
    if ($comment_author_email) {
        $dupe .= "OR comment_author_email = '{$comment_author_email}' ";
    }
    $dupe .= ") AND comment_content = '{$comment_content}' LIMIT 1";
    if ($wpdb->get_var($dupe)) {
        ajax_comment_err('重复回复,貌似您已经回复过该信息');
    }
    if ($lasttime = $wpdb->get_var($wpdb->prepare("SELECT comment_date_gmt FROM {$wpdb->comments} WHERE comment_author = %s ORDER BY comment_date DESC LIMIT 1", $comment_author))) {
        $time_lastcomment = mysql2date('U', $lasttime, false);
        $time_newcomment = mysql2date('U', current_time('mysql', 1), false);
        $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
        if ($flood_die) {
            ajax_comment_err('您回复速度太快了,请稍后在进行回复');
        }
    }
    $comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0;
    $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
    $comment_id = wp_new_comment($commentdata);
    $comment = get_comment($comment_id);
    do_action('set_comment_cookies', $comment, $user);
    $comment_depth = 1;
    $tmp_c = $comment;
    while ($tmp_c->comment_parent != 0) {
        $comment_depth++;
        $tmp_c = get_comment($tmp_c->comment_parent);
    }
    $GLOBALS['comment'] = $comment;
    //your comments here	edit start
    ?>
<li class="comments" <?php 
    comment_class(empty($args['has_children']) ? '' : 'parent');
    ?>
 id="li-comment-<?php 
    comment_ID();
    ?>
">
    <div id="comment-<?php 
    comment_ID();
//.........这里部分代码省略.........
开发者ID:qq361168780,项目名称:9IPHP,代码行数:101,代码来源:functions.php

示例5: ajax_comment_callback

function ajax_comment_callback()
{
    global $wpdb;
    $comment_post_ID = isset($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : 0;
    $post = get_post($comment_post_ID);
    $post_author = $post->post_author;
    if (empty($post->comment_status)) {
        do_action('comment_id_not_found', $comment_post_ID);
        ajax_comment_err('Invalid comment status.');
    }
    $status = get_post_status($post);
    $status_obj = get_post_status_object($status);
    if (!comments_open($comment_post_ID)) {
        do_action('comment_closed', $comment_post_ID);
        ajax_comment_err('Sorry, comments are closed for this item.');
    } elseif ('trash' == $status) {
        do_action('comment_on_trash', $comment_post_ID);
        ajax_comment_err('Invalid comment status.');
    } elseif (!$status_obj->public && !$status_obj->private) {
        do_action('comment_on_draft', $comment_post_ID);
        ajax_comment_err('Invalid comment status.');
    } elseif (post_password_required($comment_post_ID)) {
        do_action('comment_on_password_protected', $comment_post_ID);
        ajax_comment_err('Password Protected');
    } else {
        do_action('pre_comment_on_post', $comment_post_ID);
    }
    $comment_author = isset($_POST['author']) ? trim(strip_tags($_POST['author'])) : null;
    $comment_author_email = isset($_POST['email']) ? trim($_POST['email']) : null;
    $comment_author_url = isset($_POST['url']) ? trim($_POST['url']) : null;
    $comment_content = isset($_POST['comment']) ? trim($_POST['comment']) : null;
    $user = wp_get_current_user();
    if ($user->exists()) {
        if (empty($user->display_name)) {
            $user->display_name = $user->user_login;
        }
        $comment_author = esc_sql($user->display_name);
        $comment_author_email = esc_sql($user->user_email);
        $comment_author_url = esc_sql($user->user_url);
        $user_ID = esc_sql($user->ID);
        if (current_user_can('unfiltered_html')) {
            if (wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment']) {
                kses_remove_filters();
                kses_init_filters();
            }
        }
    } else {
        if (get_option('comment_registration') || 'private' == $status) {
            ajax_comment_err('Sorry, you must be logged in to post a comment.');
        }
    }
    $comment_type = '';
    if (get_option('require_name_email') && !$user->exists()) {
        if (6 > strlen($comment_author_email) || '' == $comment_author) {
            ajax_comment_err('Error: please fill the required fields (name, email).');
        } elseif (!is_email($comment_author_email)) {
            ajax_comment_err('Error: please enter a valid email address.');
        }
    }
    if ('' == $comment_content) {
        ajax_comment_err('Error: please type a comment.');
    }
    $dupe = "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = '{$comment_post_ID}' AND ( comment_author = '{$comment_author}' ";
    if ($comment_author_email) {
        $dupe .= "OR comment_author_email = '{$comment_author_email}' ";
    }
    $dupe .= ") AND comment_content = '{$comment_content}' LIMIT 1";
    if ($wpdb->get_var($dupe)) {
        ajax_comment_err('Duplicate comment detected; it looks as though you&#8217;ve already said that!');
    }
    if ($lasttime = $wpdb->get_var($wpdb->prepare("SELECT comment_date_gmt FROM {$wpdb->comments} WHERE comment_author = %s ORDER BY comment_date DESC LIMIT 1", $comment_author))) {
        $time_lastcomment = mysql2date('U', $lasttime, false);
        $time_newcomment = mysql2date('U', current_time('mysql', 1), false);
        $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
        if ($flood_die) {
            ajax_comment_err('You are posting comments too quickly.  Slow down.');
        }
    }
    $comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0;
    $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
    $comment_id = wp_new_comment($commentdata);
    $comment = get_comment($comment_id);
    do_action('set_comment_cookies', $comment, $user);
    $comment_depth = 1;
    $tmp_c = $comment;
    while ($tmp_c->comment_parent != 0) {
        $comment_depth++;
        $tmp_c = get_comment($tmp_c->comment_parent);
    }
    $GLOBALS['comment'] = $comment;
    //这里修改成你的评论结构
    ?>
    <li <?php 
    comment_class();
    ?>
 id="li-comment-<?php 
    comment_ID();
    ?>
" itemtype="http://schema.org/Comment" itemscope itemprop="comment">
		<div class="comment-holder">
//.........这里部分代码省略.........
开发者ID:happyet,项目名称:WaterFlow,代码行数:101,代码来源:functions.php

示例6: wp_ajax_replyto_comment

function wp_ajax_replyto_comment($action)
{
    global $wp_list_table, $wpdb;
    check_ajax_referer($action, '_ajax_nonce-replyto-comment');
    set_current_screen('edit-comments');
    $comment_post_ID = (int) $_POST['comment_post_ID'];
    if (!current_user_can('edit_post', $comment_post_ID)) {
        wp_die(-1);
    }
    $status = $wpdb->get_var($wpdb->prepare("SELECT post_status FROM {$wpdb->posts} WHERE ID = %d", $comment_post_ID));
    if (empty($status)) {
        wp_die(1);
    } elseif (in_array($status, array('draft', 'pending', 'trash'))) {
        wp_die(__('ERROR: you are replying to a comment on a draft post.'));
    }
    $user = wp_get_current_user();
    if ($user->ID) {
        $user_ID = $user->ID;
        $comment_author = $wpdb->escape($user->display_name);
        $comment_author_email = $wpdb->escape($user->user_email);
        $comment_author_url = $wpdb->escape($user->user_url);
        $comment_content = trim($_POST['content']);
        if (current_user_can('unfiltered_html')) {
            if (wp_create_nonce('unfiltered-html-comment') != $_POST['_wp_unfiltered_html_comment']) {
                kses_remove_filters();
                // start with a clean slate
                kses_init_filters();
                // set up the filters
            }
        }
    } else {
        wp_die(__('Sorry, you must be logged in to reply to a comment.'));
    }
    if ('' == $comment_content) {
        wp_die(__('ERROR: please type a comment.'));
    }
    $comment_parent = absint($_POST['comment_ID']);
    $comment_auto_approved = false;
    $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
    $comment_id = wp_new_comment($commentdata);
    $comment = get_comment($comment_id);
    if (!$comment) {
        wp_die(1);
    }
    $position = isset($_POST['position']) && (int) $_POST['position'] ? (int) $_POST['position'] : '-1';
    // automatically approve parent comment
    if (!empty($_POST['approve_parent'])) {
        $parent = get_comment($comment_parent);
        if ($parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID) {
            if (wp_set_comment_status($parent->comment_ID, 'approve')) {
                $comment_auto_approved = true;
            }
        }
    }
    ob_start();
    if ('dashboard' == $_REQUEST['mode']) {
        require_once ABSPATH . 'wp-admin/includes/dashboard.php';
        _wp_dashboard_recent_comments_row($comment);
    } else {
        if ('single' == $_REQUEST['mode']) {
            $wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
        } else {
            $wp_list_table = _get_list_table('WP_Comments_List_Table');
        }
        $wp_list_table->single_row($comment);
    }
    $comment_list_item = ob_get_contents();
    ob_end_clean();
    $response = array('what' => 'comment', 'id' => $comment->comment_ID, 'data' => $comment_list_item, 'position' => $position);
    if ($comment_auto_approved) {
        $response['supplemental'] = array('parent_approved' => $parent->comment_ID);
    }
    $x = new WP_Ajax_Response();
    $x->add($response);
    $x->send();
}
开发者ID:nuevomediagroup,项目名称:WordPress,代码行数:76,代码来源:ajax-actions.php

示例7: ajax_comment

function ajax_comment()
{
    global $wpdb;
    //nocache_headers();
    $comment_post_ID = isset($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : 0;
    $post = get_post($comment_post_ID);
    $post_author = $post->post_author;
    if (empty($post->comment_status)) {
        do_action('comment_id_not_found', $comment_post_ID);
        ajax_comment_err(__('Invalid comment status.', 'Lophita'));
    }
    $status = get_post_status($post);
    $status_obj = get_post_status_object($status);
    if (!comments_open($comment_post_ID)) {
        do_action('comment_closed', $comment_post_ID);
        ajax_comment_err(__('Sorry, comments are closed for this item.', 'Lophita'));
    } elseif ('trash' == $status) {
        do_action('comment_on_trash', $comment_post_ID);
        ajax_comment_err(__('Invalid comment status.', 'Lophita'));
    } elseif (!$status_obj->public && !$status_obj->private) {
        do_action('comment_on_draft', $comment_post_ID);
        ajax_comment_err(__('Invalid comment status.', 'Lophita'));
    } elseif (post_password_required($comment_post_ID)) {
        do_action('comment_on_password_protected', $comment_post_ID);
        ajax_comment_err(__('Password Protected', 'Lophita'));
    } else {
        do_action('pre_comment_on_post', $comment_post_ID);
    }
    $comment_author = isset($_POST['author']) ? trim(strip_tags($_POST['author'])) : null;
    $comment_author_email = isset($_POST['email']) ? trim($_POST['email']) : null;
    $comment_author_url = isset($_POST['url']) ? trim($_POST['url']) : null;
    $comment_content = isset($_POST['comment']) ? trim($_POST['comment']) : null;
    $edit_id = isset($_POST['edit_id']) ? $_POST['edit_id'] : null;
    $user = wp_get_current_user();
    if ($user->exists()) {
        if (empty($user->display_name)) {
            $user->display_name = $user->user_login;
        }
        $comment_author = $wpdb->escape($user->display_name);
        $comment_author_email = $wpdb->escape($user->user_email);
        $comment_author_url = $wpdb->escape($user->user_url);
        $user_ID = $wpdb->escape($user->ID);
        if (current_user_can('unfiltered_html')) {
            if (wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment']) {
                kses_remove_filters();
                kses_init_filters();
            }
        }
    } else {
        if (get_option('comment_registration') || 'private' == $status) {
            ajax_comment_err(__('Sorry, you must be logged in to post a comment.', 'Lophita'));
        }
    }
    $comment_type = '';
    if (get_option('require_name_email') && !$user->exists()) {
        if (6 > strlen($comment_author_email) || '' == $comment_author) {
            ajax_comment_err(__('Error: please fill the required fields (name, email).', 'Lophita'));
        } elseif (!is_email($comment_author_email)) {
            ajax_comment_err(__('Error: please enter a valid email address.', 'Lophita'));
        }
    }
    if ('' == $comment_content) {
        ajax_comment_err(__('Error: please type a comment.', 'Lophita'));
    }
    $dupe = "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = '{$comment_post_ID}' AND ( comment_author = '{$comment_author}' ";
    if ($comment_author_email) {
        $dupe .= "OR comment_author_email = '{$comment_author_email}' ";
    }
    $dupe .= ") AND comment_content = '{$comment_content}' LIMIT 1";
    if ($wpdb->get_var($dupe)) {
        ajax_comment_err(__('Duplicate comment detected; it looks as though you&#8217;ve already said that!', 'Lophita'));
    }
    if ($lasttime = $wpdb->get_var($wpdb->prepare("SELECT comment_date_gmt FROM {$wpdb->comments} WHERE comment_author = %s ORDER BY comment_date DESC LIMIT 1", $comment_author))) {
        $time_lastcomment = mysql2date('U', $lasttime, false);
        $time_newcomment = mysql2date('U', current_time('mysql', 1), false);
        $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
        if ($flood_die) {
            ajax_comment_err(__('You are posting comments too quickly.  Slow down.', 'Lophita'));
        }
    }
    $comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0;
    $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
    if ($edit_id) {
        $comment_id = $commentdata['comment_ID'] = $edit_id;
        if (ihacklog_user_can_edit_comment($commentdata, $comment_id)) {
            wp_update_comment($commentdata);
        } else {
            ajax_comment_err(__('Cheatin&#8217; uh?', 'Lophita'));
        }
    } else {
        $comment_id = wp_new_comment($commentdata);
    }
    $comment = get_comment($comment_id);
    do_action('set_comment_cookies', $comment, $user);
    $comment_depth = 1;
    $tmp_c = $comment;
    while ($tmp_c->comment_parent != 0) {
        $comment_depth++;
        $tmp_c = get_comment($tmp_c->comment_parent);
    }
//.........这里部分代码省略.........
开发者ID:surperone,项目名称:Lost,代码行数:101,代码来源:comments.php

示例8: kses_init

/**
 * Sets up most of the Kses filters for input form content.
 *
 * If you remove the kses_init() function from 'init' hook and
 * 'set_current_user' (priority is default), then none of the Kses filter hooks
 * will be added.
 *
 * First removes all of the Kses filters in case the current user does not need
 * to have Kses filter the content. If the user does not have unfiltered_html
 * capability, then Kses filters are added.
 *
 * @since 2.0.0
 */
function kses_init()
{
    kses_remove_filters();
    if (!current_user_can('unfiltered_html')) {
        kses_init_filters();
    }
}
开发者ID:zoran180,项目名称:wp_szf,代码行数:20,代码来源:kses.php

示例9: test_the_content_attribute_value_with_colon

    function test_the_content_attribute_value_with_colon()
    {
        kses_init_filters();
        // http://bpr3.org/?p=87
        // the title attribute should make it through unfiltered
        $post_content = <<<EOF
<span title="My friends: Alice, Bob and Carol">foo</span>
EOF;
        $expected = <<<EOF
<p><span title="My friends: Alice, Bob and Carol">foo</span></p>
EOF;
        $post_id = self::factory()->post->create(compact('post_content'));
        $this->go_to(get_permalink($post_id));
        $this->assertTrue(is_single());
        $this->assertTrue(have_posts());
        $this->assertNull(the_post());
        $this->assertEquals(strip_ws($expected), strip_ws(get_echo('the_content')));
        kses_remove_filters();
    }
开发者ID:ryelle,项目名称:WordPress,代码行数:19,代码来源:output.php

示例10: set_user

 /**
  * Set a specific user context for WordPress.
  *
  * @param array $assoc_args
  */
 private static function set_user($assoc_args)
 {
     if (isset($assoc_args['user'])) {
         $fetcher = new \WP_CLI\Fetchers\User();
         $user = $fetcher->get_check($assoc_args['user']);
         wp_set_current_user($user->ID);
     } else {
         kses_remove_filters();
     }
 }
开发者ID:Jazz-Man,项目名称:wp-cli,代码行数:15,代码来源:Runner.php

示例11: in_array

	$status = $wpdb->get_var( $wpdb->prepare("SELECT post_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) );

	if ( empty($status) )
		die('1');
	elseif ( in_array($status, array('draft', 'pending', 'trash') ) )
		die( __('Error: you are replying to a comment on a draft post.') );

	$user = wp_get_current_user();
	if ( $user->ID ) {
		$comment_author       = $wpdb->escape($user->display_name);
		$comment_author_email = $wpdb->escape($user->user_email);
		$comment_author_url   = $wpdb->escape($user->user_url);
		$comment_content      = trim($_POST['content']);
		if ( current_user_can('unfiltered_html') ) {
			if ( wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment'] ) {
				kses_remove_filters(); // start with a clean slate
				kses_init_filters(); // set up the filters
			}
		}
	} else {
		die( __('Sorry, you must be logged in to reply to a comment.') );
	}

	if ( '' == $comment_content )
		die( __('Error: please type a comment.') );

	$comment_parent = absint($_POST['comment_ID']);
	$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');

	$comment_id = wp_new_comment( $commentdata );
	$comment = get_comment($comment_id);
开发者ID:realfluid,项目名称:umbaugh,代码行数:31,代码来源:admin-ajax.php

示例12: maybe_override_kses

 function maybe_override_kses()
 {
     if (!empty($_POST) && !empty($_POST['action']) && 'editpost' == $_POST['action']) {
         if (current_user_can('unfiltered_html')) {
             // initial core cap check in kses_init() is unfilterable
             kses_remove_filters();
         }
     }
 }
开发者ID:joostrijneveld,项目名称:cscircles-wp-content,代码行数:9,代码来源:filters-admin_rs.php

示例13: kses_init

/**
 * Sets up most of the Kses filters for input form content.
 *
 * If you remove the kses_init() function from 'init' hook and
 * 'set_current_user' (priority is default), then none of the Kses filter hooks
 * will be added.
 *
 * First removes all of the Kses filters in case the current user does not need
 * to have Kses filter the content. If the user does not have unfiltered html
 * capability, then Kses filters are added.
 *
 * @uses kses_remove_filters() Removes the Kses filters
 * @uses kses_init_filters() Adds the Kses filters back if the user
 *		does not have unfiltered HTML capability.
 * @since 2.0.0
 */
function kses_init()
{
    global $allowedposttags, $allowedtags;
    $allowedposttags = apply_filters('edit_allowedposttags', $allowedposttags);
    $allowedtags = apply_filters('edit_allowedtags', $allowedtags);
    kses_remove_filters();
    kses_init_filters();
}
开发者ID:ericandrewlewis,项目名称:wordpress-mu,代码行数:24,代码来源:kses.php

示例14: ajax_comment_callback

function ajax_comment_callback()
{
    global $wpdb;
    $comment_post_ID = isset($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : 0;
    $post = get_post($comment_post_ID);
    $post_author = $post->post_author;
    if (empty($post->comment_status)) {
        do_action('comment_id_not_found', $comment_post_ID);
        ajax_comment_err('异常操作.');
    }
    $status = get_post_status($post);
    $status_obj = get_post_status_object($status);
    if (!comments_open($comment_post_ID)) {
        do_action('comment_closed', $comment_post_ID);
        ajax_comment_err('对不起,评论已经关闭');
    } elseif ('trash' == $status) {
        do_action('comment_on_trash', $comment_post_ID);
        ajax_comment_err('对此条评论的回复功能暂不可用.');
    } elseif (!$status_obj->public && !$status_obj->private) {
        do_action('comment_on_draft', $comment_post_ID);
        ajax_comment_err('对此条评论的回复功能暂不可用..');
    } elseif (post_password_required($comment_post_ID)) {
        do_action('comment_on_password_protected', $comment_post_ID);
        ajax_comment_err('文章受到密码保护');
    } else {
        do_action('pre_comment_on_post', $comment_post_ID);
    }
    $comment_author = isset($_POST['author']) ? trim(strip_tags($_POST['author'])) : null;
    $comment_author_email = isset($_POST['email']) ? trim($_POST['email']) : null;
    $comment_author_url = isset($_POST['url']) ? trim($_POST['url']) : null;
    $comment_content = isset($_POST['comment']) ? trim($_POST['comment']) : null;
    $user = wp_get_current_user();
    if ($user->exists()) {
        if (empty($user->display_name)) {
            $user->display_name = $user->user_login;
        }
        $comment_author = esc_sql($user->display_name);
        $comment_author_email = esc_sql($user->user_email);
        $comment_author_url = esc_sql($user->user_url);
        $user_ID = esc_sql($user->ID);
        if (current_user_can('unfiltered_html')) {
            if (wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment']) {
                kses_remove_filters();
                kses_init_filters();
            }
        }
    } else {
        if (get_option('comment_registration') || 'private' == $status) {
            ajax_comment_err('错误:你必须登陆以添加评论.');
        }
    }
    $comment_type = '';
    if (get_option('require_name_email') && !$user->exists()) {
        if (6 > strlen($comment_author_email) || '' == $comment_author) {
            ajax_comment_err('错误:至少需要填写有效的名字与邮箱地址.');
        } elseif (!is_email($comment_author_email)) {
            ajax_comment_err('错误:邮箱地址无效.');
        }
    }
    if ('' == $comment_content) {
        ajax_comment_err('错误:忘写评论内容了?');
    }
    $dupe = "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = '{$comment_post_ID}' AND ( comment_author = '{$comment_author}' ";
    if ($comment_author_email) {
        $dupe .= "OR comment_author_email = '{$comment_author_email}' ";
    }
    $dupe .= ") AND comment_content = '{$comment_content}' LIMIT 1";
    if ($wpdb->get_var($dupe)) {
        ajax_comment_err('错误:检测到重复评论,说明您已经递交过相同内容.');
    }
    if ($lasttime = $wpdb->get_var($wpdb->prepare("SELECT comment_date_gmt FROM {$wpdb->comments} WHERE comment_author = %s ORDER BY comment_date DESC LIMIT 1", $comment_author))) {
        $time_lastcomment = mysql2date('U', $lasttime, false);
        $time_newcomment = mysql2date('U', current_time('mysql', 1), false);
        $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
        if ($flood_die) {
            ajax_comment_err('错误:评论递交频率太快.');
        }
    }
    $comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0;
    $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
    $comment_id = wp_new_comment($commentdata);
    $comment = get_comment($comment_id);
    do_action('set_comment_cookies', $comment, $user);
    $comment_depth = 1;
    $tmp_c = $comment;
    while ($tmp_c->comment_parent != 0) {
        $comment_depth++;
        $tmp_c = get_comment($tmp_c->comment_parent);
    }
    $GLOBALS['comment'] = $comment;
    //这里修改成你的评论结构
    ?>
    <li <?php 
    comment_class();
    ?>
>
        <article class="comment-body clear">
            <footer class="comment-meta">
                <div class="comment-author vcard">
                    <?php 
//.........这里部分代码省略.........
开发者ID:qiansen1386,项目名称:LunarLoveS,代码行数:101,代码来源:ajax-comment-init.php

示例15: save_post_translation

 function save_post_translation($translation_id, $translation)
 {
     global $wpdb, $sitepress_settings, $sitepress, $icl_adjust_id_url_filter_off;
     $icl_adjust_id_url_filter_off = true;
     $translation_info = $wpdb->get_row($wpdb->prepare("\n                SELECT * FROM {$wpdb->prefix}icl_translations tr\n                    JOIN {$wpdb->prefix}icl_translation_status ts ON ts.translation_id = tr.translation_id\n                WHERE tr.translation_id=%d", $translation_id));
     $lang_code = $translation_info->language_code;
     $trid = $translation_info->trid;
     $original_post_details = $wpdb->get_row("\n            SELECT p.post_author, p.post_type, p.post_status, p.comment_status, p.ping_status, p.post_parent, p.menu_order, p.post_date, t.language_code\n            FROM {$wpdb->prefix}icl_translations t \n            JOIN {$wpdb->posts} p ON t.element_id = p.ID AND CONCAT('post_',p.post_type) = t.element_type\n            WHERE trid='{$trid}' AND p.ID = '{$translation['original_id']}'\n        ");
     //is the original post a sticky post?
     $sticky_posts = get_option('sticky_posts');
     $is_original_sticky = $original_post_details->post_type == 'post' && in_array($translation['original_id'], $sticky_posts);
     $this->_content_fix_image_paths_in_body($translation);
     $this->_content_fix_relative_link_paths_in_body($translation);
     $this->_content_decode_shortcodes($translation);
     // handle the page parent and set it to the translated parent if we have one.
     if ($original_post_details->post_parent) {
         $post_parent_trid = $wpdb->get_var($wpdb->prepare("\tSELECT trid\n\t\t\t\t\t\tFROM {$wpdb->prefix}icl_translations\n\t\t\t\t\t\tWHERE element_type= %s AND element_id = %d ", 'post_' . $original_post_details->post_type, $original_post_details->post_parent));
         if ($post_parent_trid) {
             $parent_id = $wpdb->get_var($wpdb->prepare("SELECT element_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t FROM {$wpdb->prefix}icl_translations\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE element_type = %s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  AND trid = %d\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  AND language_code = %s ", 'post_' . $original_post_details->post_type, $post_parent_trid, $lang_code));
         }
     }
     // determine post id based on trid
     $post_id = $translation_info->element_id;
     if ($post_id) {
         // see if the post really exists - make sure it wasn't deleted while the plugin was
         if (!$wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE ID = %d ", $post_id))) {
             $is_update = false;
             $q = "DELETE FROM {$wpdb->prefix}icl_translations WHERE element_type=%s AND element_id=%d";
             $q_prepared = $wpdb->prepare($q, array('post_' . $original_post_details->post_type, $post_id));
             $wpdb->query($q_prepared);
         } else {
             $is_update = true;
             $postarr['ID'] = $_POST['post_ID'] = $post_id;
         }
     } else {
         $is_update = false;
     }
     $postarr['post_title'] = $translation['title'];
     if ($sitepress_settings['translated_document_page_url'] == 'translate' && isset($translation['URL'])) {
         $postarr['post_name'] = $translation['URL'];
     }
     $postarr['post_content'] = $translation['body'];
     if (isset($translation['excerpt']) && $translation['excerpt'] != "") {
         $postarr['post_excerpt'] = $translation['excerpt'];
     }
     if (isset($translated_taxonomies) && is_array($translated_taxonomies)) {
         foreach ($translated_taxonomies as $taxonomy => $values) {
             $postarr['tax_input'][$taxonomy] = join(',', (array) $values);
         }
     }
     $postarr['post_author'] = $original_post_details->post_author;
     $postarr['post_type'] = $original_post_details->post_type;
     if ($sitepress_settings['sync_comment_status']) {
         $postarr['comment_status'] = $original_post_details->comment_status;
     }
     if ($sitepress_settings['sync_ping_status']) {
         $postarr['ping_status'] = $original_post_details->ping_status;
     }
     if ($sitepress_settings['sync_page_ordering']) {
         $postarr['menu_order'] = $original_post_details->menu_order;
     }
     if ($sitepress_settings['sync_private_flag'] && $original_post_details->post_status == 'private') {
         $postarr['post_status'] = 'private';
     }
     if (!$is_update) {
         $postarr['post_status'] = !$sitepress_settings['translated_document_status'] ? 'draft' : $original_post_details->post_status;
     } else {
         // set post_status to the current post status.
         $postarr['post_status'] = $wpdb->get_var($wpdb->prepare("SELECT post_status\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t FROM {$wpdb->prefix}posts\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE ID = %d ", $post_id));
     }
     if ($sitepress_settings['sync_post_date']) {
         $postarr['post_date'] = $original_post_details->post_date;
     }
     if (isset($parent_id) && $sitepress_settings['sync_page_parent']) {
         $_POST['post_parent'] = $postarr['post_parent'] = $parent_id;
         $_POST['parent_id'] = $postarr['parent_id'] = $parent_id;
     }
     if ($is_update) {
         $postarr['post_name'] = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM {$wpdb->posts} WHERE ID=%d", $post_id));
     }
     $_POST['trid'] = $trid;
     $_POST['lang'] = $lang_code;
     $_POST['skip_sitepress_actions'] = true;
     global $wp_rewrite;
     if (!isset($wp_rewrite)) {
         $wp_rewrite = new WP_Rewrite();
     }
     kses_remove_filters();
     $postarr = apply_filters('icl_pre_save_pro_translation', $postarr);
     $new_post_id = wp_insert_post($postarr);
     do_action('icl_pro_translation_saved', $new_post_id);
     // set stickiness
     if ($is_original_sticky && $sitepress_settings['sync_sticky_flag']) {
         stick_post($new_post_id);
     } else {
         if ($original_post_details->post_type == 'post' && $is_update) {
             unstick_post($new_post_id);
             //just in case - if this is an update and the original post stckiness has changed since the post was sent to translation
         }
     }
//.........这里部分代码省略.........
开发者ID:ryuqing,项目名称:cake,代码行数:101,代码来源:wpml-pro-translation.class.php


注:本文中的kses_remove_filters函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。