本文整理汇总了PHP中bbp_filter_anonymous_post_data函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_filter_anonymous_post_data函数的具体用法?PHP bbp_filter_anonymous_post_data怎么用?PHP bbp_filter_anonymous_post_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_filter_anonymous_post_data函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bbp_edit_topic_handler
/**
* Handles the front end edit topic submission
*
* @param string $action The requested action to compare this function to
* @uses bbp_add_error() To add an error message
* @uses bbp_get_topic() To get the topic
* @uses bbp_verify_nonce_request() To verify the nonce and check the request
* @uses bbp_is_topic_anonymous() To check if topic is by an anonymous user
* @uses current_user_can() To check if the current user can edit the topic
* @uses bbp_filter_anonymous_post_data() To filter anonymous data
* @uses is_wp_error() To check if the value retrieved is a {@link WP_Error}
* @uses esc_attr() For sanitization
* @uses bbp_is_forum_category() To check if the forum is a category
* @uses bbp_is_forum_closed() To check if the forum is closed
* @uses bbp_is_forum_private() To check if the forum is private
* @uses remove_filter() To remove kses filters if needed
* @uses apply_filters() Calls 'bbp_edit_topic_pre_title' with the title and
* topic id
* @uses apply_filters() Calls 'bbp_edit_topic_pre_content' with the content
* and topic id
* @uses bbPress::errors::get_error_codes() To get the {@link WP_Error} errors
* @uses wp_save_post_revision() To save a topic revision
* @uses bbp_update_topic_revision_log() To update the topic revision log
* @uses bbp_stick_topic() To stick or super stick the topic
* @uses bbp_unstick_topic() To unstick the topic
* @uses wp_update_post() To update the topic
* @uses do_action() Calls 'bbp_edit_topic' with the topic id, forum id,
* anonymous data and reply author
* @uses bbp_move_topic_handler() To handle movement of a topic from one forum
* to another
* @uses bbp_get_topic_permalink() To get the topic permalink
* @uses wp_safe_redirect() To redirect to the topic link
* @uses bbPress::errors::get_error_messages() To get the {@link WP_Error} error
* messages
*/
function bbp_edit_topic_handler($action = '')
{
// Bail if action is not bbp-edit-topic
if ('bbp-edit-topic' !== $action) {
return;
}
// Define local variable(s)
$revisions_removed = false;
$topic = $topic_id = $topic_author = $forum_id = $anonymous_data = 0;
$topic_title = $topic_content = $topic_edit_reason = '';
/** Topic *****************************************************************/
// Topic id was not passed
if (empty($_POST['bbp_topic_id'])) {
bbp_add_error('bbp_edit_topic_id', __('<strong>ERROR</strong>: Topic ID not found.', 'bbpress'));
return;
// Topic id was passed
} elseif (is_numeric($_POST['bbp_topic_id'])) {
$topic_id = (int) $_POST['bbp_topic_id'];
$topic = bbp_get_topic($topic_id);
}
// Topic does not exist
if (empty($topic)) {
bbp_add_error('bbp_edit_topic_not_found', __('<strong>ERROR</strong>: The topic you want to edit was not found.', 'bbpress'));
return;
// Topic exists
} else {
// Check users ability to create new topic
if (!bbp_is_topic_anonymous($topic_id)) {
// User cannot edit this topic
if (!current_user_can('edit_topic', $topic_id)) {
bbp_add_error('bbp_edit_topic_permissions', __('<strong>ERROR</strong>: You do not have permission to edit that topic.', 'bbpress'));
}
// Set topic author
$topic_author = bbp_get_topic_author_id($topic_id);
// It is an anonymous post
} else {
// Filter anonymous data
$anonymous_data = bbp_filter_anonymous_post_data(array(), true);
}
}
// Nonce check
if (!bbp_verify_nonce_request('bbp-edit-topic_' . $topic_id)) {
bbp_add_error('bbp_edit_topic_nonce', __('<strong>ERROR</strong>: Are you sure you wanted to do that?', 'bbpress'));
return;
}
// Remove kses filters from title and content for capable users and if the nonce is verified
if (current_user_can('unfiltered_html') && !empty($_POST['_bbp_unfiltered_html_topic']) && wp_create_nonce('bbp-unfiltered-html-topic_' . $topic_id) === $_POST['_bbp_unfiltered_html_topic']) {
remove_filter('bbp_edit_topic_pre_title', 'wp_filter_kses');
remove_filter('bbp_edit_topic_pre_content', 'bbp_encode_bad', 10);
remove_filter('bbp_edit_topic_pre_content', 'bbp_filter_kses', 30);
}
/** Topic Forum ***********************************************************/
// Forum id was not passed
if (empty($_POST['bbp_forum_id'])) {
bbp_add_error('bbp_topic_forum_id', __('<strong>ERROR</strong>: Forum ID is missing.', 'bbpress'));
// Forum id was passed
} elseif (is_numeric($_POST['bbp_forum_id'])) {
$forum_id = (int) $_POST['bbp_forum_id'];
}
// Current forum this topic is in
$current_forum_id = bbp_get_topic_forum_id($topic_id);
// Forum exists
if (!empty($forum_id) && $forum_id !== $current_forum_id) {
// Forum is a category
if (bbp_is_forum_category($forum_id)) {
//.........这里部分代码省略.........
示例2: attributes_metabox_save
/**
* Pass the reply attributes for processing
*
* @since 2.0.0 bbPress (r2746)
*
* @param int $reply_id Reply id
* @uses current_user_can() To check if the current user is capable of
* editing the reply
* @uses do_action() Calls 'bbp_reply_attributes_metabox_save' with the
* reply id and parent id
* @return int Parent id
*/
public function attributes_metabox_save($reply_id)
{
if ($this->bail()) {
return $reply_id;
}
// Bail if doing an autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $reply_id;
}
// Bail if not a post request
if (!bbp_is_post_request()) {
return $reply_id;
}
// Check action exists
if (empty($_POST['action'])) {
return $reply_id;
}
// Nonce check
if (empty($_POST['bbp_reply_metabox']) || !wp_verify_nonce($_POST['bbp_reply_metabox'], 'bbp_reply_metabox_save')) {
return $reply_id;
}
// Current user cannot edit this reply
if (!current_user_can('edit_reply', $reply_id)) {
return $reply_id;
}
// Get the reply meta post values
$topic_id = !empty($_POST['parent_id']) ? (int) $_POST['parent_id'] : 0;
$forum_id = !empty($_POST['bbp_forum_id']) ? (int) $_POST['bbp_forum_id'] : bbp_get_topic_forum_id($topic_id);
$reply_to = !empty($_POST['bbp_reply_to']) ? (int) $_POST['bbp_reply_to'] : 0;
// Get reply author data
$anonymous_data = bbp_filter_anonymous_post_data();
$author_id = bbp_get_reply_author_id($reply_id);
$is_edit = isset($_POST['hidden_post_status']) && $_POST['hidden_post_status'] !== 'draft';
// Formally update the reply
bbp_update_reply($reply_id, $topic_id, $forum_id, $anonymous_data, $author_id, $is_edit, $reply_to);
// Allow other fun things to happen
do_action('bbp_reply_attributes_metabox_save', $reply_id, $topic_id, $forum_id, $reply_to);
do_action('bbp_author_metabox_save', $reply_id, $anonymous_data);
return $reply_id;
}
示例3: bbp_edit_reply_handler
/**
* Handles the front end edit reply submission
*
* @param string $action The requested action to compare this function to
* @uses bbp_add_error() To add an error message
* @uses bbp_get_reply() To get the reply
* @uses bbp_verify_nonce_request() To verify the nonce and check the request
* @uses bbp_is_reply_anonymous() To check if the reply was by an anonymous user
* @uses current_user_can() To check if the current user can edit that reply
* @uses bbp_filter_anonymous_post_data() To filter anonymous data
* @uses is_wp_error() To check if the value retrieved is a {@link WP_Error}
* @uses remove_filter() To remove kses filters if needed
* @uses esc_attr() For sanitization
* @uses apply_filters() Calls 'bbp_edit_reply_pre_title' with the title and
* reply id
* @uses apply_filters() Calls 'bbp_edit_reply_pre_content' with the content
* reply id
* @uses wp_set_post_terms() To set the topic tags
* @uses bbp_has_errors() To get the {@link WP_Error} errors
* @uses wp_save_post_revision() To save a reply revision
* @uses bbp_update_reply_revision_log() To update the reply revision log
* @uses wp_update_post() To update the reply
* @uses bbp_get_reply_topic_id() To get the reply topic id
* @uses bbp_get_topic_forum_id() To get the topic forum id
* @uses bbp_get_reply_to() To get the reply to id
* @uses do_action() Calls 'bbp_edit_reply' with the reply id, topic id, forum
* id, anonymous data, reply author, bool true (for edit),
* and the reply to id
* @uses bbp_get_reply_url() To get the paginated url to the reply
* @uses wp_safe_redirect() To redirect to the reply url
* @uses bbPress::errors::get_error_message() To get the {@link WP_Error} error
* message
*/
function bbp_edit_reply_handler($action = '')
{
// Bail if action is not bbp-edit-reply
if ('bbp-edit-reply' !== $action) {
return;
}
// Define local variable(s)
$revisions_removed = false;
$reply = $reply_id = $reply_author = $topic_id = $forum_id = $anonymous_data = 0;
$reply_title = $reply_content = $reply_edit_reason = $terms = '';
/** Reply *****************************************************************/
// Reply id was not passed
if (empty($_POST['bbp_reply_id'])) {
bbp_add_error('bbp_edit_reply_id', __('<strong>ERROR</strong>: Reply ID not found.', 'bbpress'));
return;
// Reply id was passed
} elseif (is_numeric($_POST['bbp_reply_id'])) {
$reply_id = (int) $_POST['bbp_reply_id'];
$reply = bbp_get_reply($reply_id);
}
// Nonce check
if (!bbp_verify_nonce_request('bbp-edit-reply_' . $reply_id)) {
bbp_add_error('bbp_edit_reply_nonce', __('<strong>ERROR</strong>: Are you sure you wanted to do that?', 'bbpress'));
return;
}
// Reply does not exist
if (empty($reply)) {
bbp_add_error('bbp_edit_reply_not_found', __('<strong>ERROR</strong>: The reply you want to edit was not found.', 'bbpress'));
return;
// Reply exists
} else {
// Check users ability to create new reply
if (!bbp_is_reply_anonymous($reply_id)) {
// User cannot edit this reply
if (!current_user_can('edit_reply', $reply_id)) {
bbp_add_error('bbp_edit_reply_permissions', __('<strong>ERROR</strong>: You do not have permission to edit that reply.', 'bbpress'));
return;
}
// Set reply author
$reply_author = bbp_get_reply_author_id($reply_id);
// It is an anonymous post
} else {
// Filter anonymous data
$anonymous_data = bbp_filter_anonymous_post_data();
}
}
// Remove kses filters from title and content for capable users and if the nonce is verified
if (current_user_can('unfiltered_html') && !empty($_POST['_bbp_unfiltered_html_reply']) && wp_create_nonce('bbp-unfiltered-html-reply_' . $reply_id) === $_POST['_bbp_unfiltered_html_reply']) {
remove_filter('bbp_edit_reply_pre_title', 'wp_filter_kses');
remove_filter('bbp_edit_reply_pre_content', 'bbp_encode_bad', 10);
remove_filter('bbp_edit_reply_pre_content', 'bbp_filter_kses', 30);
}
/** Reply Topic ***********************************************************/
$topic_id = bbp_get_reply_topic_id($reply_id);
/** Topic Forum ***********************************************************/
$forum_id = bbp_get_topic_forum_id($topic_id);
// Forum exists
if (!empty($forum_id) && $forum_id !== bbp_get_reply_forum_id($reply_id)) {
// Forum is a category
if (bbp_is_forum_category($forum_id)) {
bbp_add_error('bbp_edit_reply_forum_category', __('<strong>ERROR</strong>: This forum is a category. No replies can be created in this forum.', 'bbpress'));
// Forum is not a category
} else {
// Forum is closed and user cannot access
if (bbp_is_forum_closed($forum_id) && !current_user_can('edit_forum', $forum_id)) {
bbp_add_error('bbp_edit_reply_forum_closed', __('<strong>ERROR</strong>: This forum has been closed to new replies.', 'bbpress'));
}
//.........这里部分代码省略.........
示例4: attributes_metabox_save
/**
* Pass the topic attributes for processing
*
* @since 2.0.0 bbPress (r2746)
*
* @param int $topic_id Topic id
* @uses current_user_can() To check if the current user is capable of
* editing the topic
* @uses do_action() Calls 'bbp_topic_attributes_metabox_save' with the
* topic id and parent id
* @return int Parent id
*/
public function attributes_metabox_save($topic_id)
{
if ($this->bail()) {
return $topic_id;
}
// Bail if doing an autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $topic_id;
}
// Bail if not a post request
if (!bbp_is_post_request()) {
return $topic_id;
}
// Nonce check
if (empty($_POST['bbp_topic_metabox']) || !wp_verify_nonce($_POST['bbp_topic_metabox'], 'bbp_topic_metabox_save')) {
return $topic_id;
}
// Bail if current user cannot edit this topic
if (!current_user_can('edit_topic', $topic_id)) {
return $topic_id;
}
// Get the forum ID
$forum_id = !empty($_POST['parent_id']) ? (int) $_POST['parent_id'] : 0;
// Get topic author data
$anonymous_data = bbp_filter_anonymous_post_data();
$author_id = bbp_get_topic_author_id($topic_id);
$is_edit = isset($_POST['hidden_post_status']) && $_POST['hidden_post_status'] !== 'draft';
// Formally update the topic
bbp_update_topic($topic_id, $forum_id, $anonymous_data, $author_id, $is_edit);
// Stickies
if (!empty($_POST['bbp_stick_topic']) && in_array($_POST['bbp_stick_topic'], array('stick', 'super', 'unstick'))) {
// What's the haps?
switch ($_POST['bbp_stick_topic']) {
// Sticky in this forum
case 'stick':
bbp_stick_topic($topic_id);
break;
// Super sticky in all forums
// Super sticky in all forums
case 'super':
bbp_stick_topic($topic_id, true);
break;
// Normal
// Normal
case 'unstick':
default:
bbp_unstick_topic($topic_id);
break;
}
}
// Allow other fun things to happen
do_action('bbp_topic_attributes_metabox_save', $topic_id, $forum_id);
do_action('bbp_author_metabox_save', $topic_id, $anonymous_data);
return $topic_id;
}
示例5: update_post_meta
/**
* Update post meta after a spam check
*
* @since bbPress (r3308)
*
* @param int $post_id
* @param object $_post
*
* @global object $this->last_post
*
* @uses get_post() To get the post object
* @uses get_userdata() To get the user data
* @uses bbp_filter_anonymous_user_data() To get anonymous user data
* @uses update_post_meta() To update post meta with Akismet data
* @uses BBP_Akismet::update_post_history() To update post Akismet history
*/
public function update_post_meta($post_id = 0, $_post = false)
{
// Define local variable(s)
$as_submitted = false;
// Setup some variables
$post_id = (int) $post_id;
// Ensure we have a post object
if (empty($_post)) {
$_post = get_post($post_id);
}
// Set up Akismet last post data
if (!empty($this->last_post)) {
$as_submitted = $this->last_post['bbp_post_as_submitted'];
}
// wp_insert_post() might be called in other contexts. Ensure this is
// the same topic/reply as was checked by BBP_Akismet::check_post()
if (is_object($_post) && !empty($this->last_post) && is_array($as_submitted)) {
// Get user data
$userdata = get_userdata($_post->post_author);
$anonymous_data = bbp_filter_anonymous_post_data();
// More checks
if (intval($as_submitted['comment_post_ID']) == intval($_post->post_parent) && $as_submitted['comment_author'] == ($anonymous_data ? $anonymous_data['bbp_anonymous_name'] : $userdata->display_name) && $as_submitted['comment_author_email'] == ($anonymous_data ? $anonymous_data['bbp_anonymous_email'] : $userdata->user_email)) {
// Normal result: true
if ($this->last_post['bbp_akismet_result'] == 'true') {
// Leave a trail so other's know what we did
update_post_meta($post_id, '_bbp_akismet_result', 'true');
$this->update_post_history($post_id, __('Akismet caught this post as spam', 'bbpress'), 'check-spam');
// If post_status isn't the spam status, as expected, leave a note
if ($_post->post_status != bbp_get_spam_status_id()) {
$this->update_post_history($post_id, sprintf(__('Post status was changed to %s', 'bbpress'), $_post->post_status), 'status-changed-' . $_post->post_status);
}
// Normal result: false
} elseif ($this->last_post['bbp_akismet_result'] == 'false') {
// Leave a trail so other's know what we did
update_post_meta($post_id, '_bbp_akismet_result', 'false');
$this->update_post_history($post_id, __('Akismet cleared this post', 'bbpress'), 'check-ham');
// If post_status is the spam status, which isn't expected, leave a note
if ($_post->post_status == bbp_get_spam_status_id()) {
// @todo Use wp_blacklist_check()
$this->update_post_history($post_id, sprintf(__('Post status was changed to %s', 'bbpress'), $_post->post_status), 'status-changed-' . $_post->post_status);
}
// Abnormal result: error
} else {
// Leave a trail so other's know what we did
update_post_meta($post_id, '_bbp_akismet_error', time());
$this->update_post_history($post_id, sprintf(__('Akismet was unable to check this post (response: %s), will automatically retry again later.', 'bbpress'), $this->last_post['bbp_akismet_result']), 'check-error');
}
// Record the complete original data as submitted for checking
if (isset($this->last_post['bbp_post_as_submitted'])) {
update_post_meta($post_id, '_bbp_akismet_as_submitted', $this->last_post['bbp_post_as_submitted']);
}
}
}
}
示例6: author_metabox_save
/**
* Save the author information for the topic
*
* @since bbPress (r2828)
*
* @param int $post_id Topic or reply id
* @uses bbp_get_topic() To get the topic
* @uses bbp_get_reply() To get the reply
* @uses current_user_can() To check if the current user can edit the
* topic or reply
* @uses bbp_filter_author_post_data() To filter the author data
* @uses update_post_meta() To update the anonymous user data
* @uses do_action() Calls 'bbp_author_metabox_save' with the topic id and
* anonymous data
* @return int Topic or reply id
*/
public function author_metabox_save($post_id)
{
if ($this->bail()) {
return $post_id;
}
// Bail if no post_id
if (empty($post_id)) {
return $post_id;
}
// Bail if doing an autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// Bail if not a post request
if ('POST' != strtoupper($_SERVER['REQUEST_METHOD'])) {
return $post_id;
}
// Bail if user cannot edit topics
if (!current_user_can('edit_topic', $post_id)) {
return $post_id;
}
$anonymous_data = bbp_filter_anonymous_post_data();
update_post_meta($post_id, '_bbp_anonymous_name', $anonymous_data['bbp_anonymous_name']);
update_post_meta($post_id, '_bbp_anonymous_email', $anonymous_data['bbp_anonymous_email']);
update_post_meta($post_id, '_bbp_anonymous_website', $anonymous_data['bbp_anonymous_website']);
do_action('bbp_author_metabox_save', $post_id, $anonymous_data);
return $post_id;
}
示例7: save_meta_boxes
/**
* Pass the topic attributes for processing
*
* @since 2.0.0 bbPress (r2746)
*
* @param int $topic_id Topic id
* @uses current_user_can() To check if the current user is capable of
* editing the topic
* @uses do_action() Calls 'bbp_topic_attributes_metabox_save' with the
* topic id and parent id
* @return int Parent id
*/
public function save_meta_boxes($topic_id)
{
if ($this->bail()) {
return $topic_id;
}
// Bail if doing an autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $topic_id;
}
// Bail if not a post request
if (!bbp_is_post_request()) {
return $topic_id;
}
// Nonce check
if (empty($_POST['bbp_topic_metabox']) || !wp_verify_nonce($_POST['bbp_topic_metabox'], 'bbp_topic_metabox_save')) {
return $topic_id;
}
// Bail if current user cannot edit this topic
if (!current_user_can('edit_topic', $topic_id)) {
return $topic_id;
}
// Get the forum ID
$forum_id = !empty($_POST['parent_id']) ? (int) $_POST['parent_id'] : 0;
// Get topic author data
$anonymous_data = bbp_filter_anonymous_post_data();
$author_id = bbp_get_topic_author_id($topic_id);
$is_edit = isset($_POST['hidden_post_status']) && $_POST['hidden_post_status'] !== 'draft';
// Formally update the topic
bbp_update_topic($topic_id, $forum_id, $anonymous_data, $author_id, $is_edit);
// Allow other fun things to happen
do_action('bbp_topic_attributes_metabox_save', $topic_id, $forum_id);
do_action('bbp_author_metabox_save', $topic_id, $anonymous_data);
return $topic_id;
}