本文整理汇总了PHP中bbp_is_topic_spam函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_is_topic_spam函数的具体用法?PHP bbp_is_topic_spam怎么用?PHP bbp_is_topic_spam使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_is_topic_spam函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bbp_get_form_topic_tags
/**
* Return value of topic tags field
*
* @since 2.0.0 bbPress (r2976)
*
* @uses bbp_is_topic_edit() To check if it's the topic edit page
* @uses apply_filters() Calls 'bbp_get_form_topic_tags' with the tags
* @return string Value of topic tags field
*/
function bbp_get_form_topic_tags()
{
// Default return value
$topic_tags = '';
// Get _POST data
if ((bbp_is_topic_form_post_request() || bbp_is_reply_form_post_request()) && isset($_POST['bbp_topic_tags'])) {
$topic_tags = wp_unslash($_POST['bbp_topic_tags']);
// Get edit data
} elseif (bbp_is_single_topic() || bbp_is_single_reply() || bbp_is_topic_edit() || bbp_is_reply_edit()) {
// Determine the topic id based on the post type
switch (get_post_type()) {
// Post is a topic
case bbp_get_topic_post_type():
$topic_id = bbp_get_topic_id(get_the_ID());
break;
// Post is a reply
// Post is a reply
case bbp_get_reply_post_type():
$topic_id = bbp_get_reply_topic_id(get_the_ID());
break;
}
// Topic exists
if (!empty($topic_id)) {
// Topic is spammed so display pre-spam terms
if (bbp_is_topic_spam($topic_id)) {
// Get pre-spam terms
$spam_terms = get_post_meta($topic_id, '_bbp_spam_topic_tags', true);
$topic_tags = !empty($spam_terms) ? implode(', ', $spam_terms) : '';
// Topic is not spam so get real terms
} else {
$topic_tags = bbp_get_topic_tag_names($topic_id);
}
}
}
return apply_filters('bbp_get_form_topic_tags', $topic_tags);
}
示例2: do_action
do_action('bbp_theme_before_reply_form_tags');
?>
<p>
<label for="bbp_topic_tags"><?php
esc_html_e('Tags:', 'monsoon');
?>
</label><br />
<input type="text" value="<?php
bbp_form_topic_tags();
?>
" tabindex="<?php
bbp_tab_index();
?>
" size="40" name="bbp_topic_tags" id="bbp_topic_tags" <?php
disabled(bbp_is_topic_spam());
?>
/>
</p>
<?php
do_action('bbp_theme_after_reply_form_tags');
?>
<?php
}
?>
<?php
if (bbp_is_subscriptions_active() && !bbp_is_anonymous() && (!bbp_is_reply_edit() || bbp_is_reply_edit() && !bbp_is_reply_anonymous())) {
?>
示例3: bbp_new_reply_handler
//.........这里部分代码省略.........
// Default
} else {
$reply_status = bbp_get_public_status_id();
}
/** Reply To **************************************************************/
// Handle Reply To of the reply; $_REQUEST for non-JS submissions
if (isset($_REQUEST['bbp_reply_to'])) {
$reply_to = bbp_validate_reply_to($_REQUEST['bbp_reply_to']);
}
/** Topic Closed **********************************************************/
// If topic is closed, moderators can still reply
if (bbp_is_topic_closed($topic_id) && !current_user_can('moderate')) {
bbp_add_error('bbp_reply_topic_closed', __('<strong>ERROR</strong>: Topic is closed.', 'bbpress'));
}
/** Topic Tags ************************************************************/
// Either replace terms
if (bbp_allow_topic_tags() && current_user_can('assign_topic_tags') && !empty($_POST['bbp_topic_tags'])) {
$terms = esc_attr(strip_tags($_POST['bbp_topic_tags']));
// ...or remove them.
} elseif (isset($_POST['bbp_topic_tags'])) {
$terms = '';
// Existing terms
} else {
$terms = bbp_get_topic_tag_names($topic_id);
}
/** Additional Actions (Before Save) **************************************/
do_action('bbp_new_reply_pre_extras', $topic_id, $forum_id);
// Bail if errors
if (bbp_has_errors()) {
return;
}
/** No Errors *************************************************************/
// Add the content of the form to $reply_data as an array
// Just in time manipulation of reply data before being created
$reply_data = apply_filters('bbp_new_reply_pre_insert', array('post_author' => $reply_author, 'post_title' => $reply_title, 'post_content' => $reply_content, 'post_status' => $reply_status, 'post_parent' => $topic_id, 'post_type' => bbp_get_reply_post_type(), 'comment_status' => 'closed', 'menu_order' => bbp_get_topic_reply_count($topic_id, false) + 1));
// Insert reply
$reply_id = wp_insert_post($reply_data);
/** No Errors *************************************************************/
// Check for missing reply_id or error
if (!empty($reply_id) && !is_wp_error($reply_id)) {
/** Topic Tags ********************************************************/
// Just in time manipulation of reply terms before being edited
$terms = apply_filters('bbp_new_reply_pre_set_terms', $terms, $topic_id, $reply_id);
// Insert terms
$terms = wp_set_post_terms($topic_id, $terms, bbp_get_topic_tag_tax_id(), false);
// Term error
if (is_wp_error($terms)) {
bbp_add_error('bbp_reply_tags', __('<strong>ERROR</strong>: There was a problem adding the tags to the topic.', 'bbpress'));
}
/** Trash Check *******************************************************/
// If this reply starts as trash, add it to pre_trashed_replies
// for the topic, so it is properly restored.
if (bbp_is_topic_trash($topic_id) || $reply_data['post_status'] === bbp_get_trash_status_id()) {
// Trash the reply
wp_trash_post($reply_id);
// Only add to pre-trashed array if topic is trashed
if (bbp_is_topic_trash($topic_id)) {
// Get pre_trashed_replies for topic
$pre_trashed_replies = get_post_meta($topic_id, '_bbp_pre_trashed_replies', true);
// Add this reply to the end of the existing replies
$pre_trashed_replies[] = $reply_id;
// Update the pre_trashed_reply post meta
update_post_meta($topic_id, '_bbp_pre_trashed_replies', $pre_trashed_replies);
}
/** Spam Check ********************************************************/
// If reply or topic are spam, officially spam this reply
} elseif (bbp_is_topic_spam($topic_id) || $reply_data['post_status'] === bbp_get_spam_status_id()) {
add_post_meta($reply_id, '_bbp_spam_meta_status', bbp_get_public_status_id());
// Only add to pre-spammed array if topic is spam
if (bbp_is_topic_spam($topic_id)) {
// Get pre_spammed_replies for topic
$pre_spammed_replies = get_post_meta($topic_id, '_bbp_pre_spammed_replies', true);
// Add this reply to the end of the existing replies
$pre_spammed_replies[] = $reply_id;
// Update the pre_spammed_replies post meta
update_post_meta($topic_id, '_bbp_pre_spammed_replies', $pre_spammed_replies);
}
}
/** Update counts, etc... *********************************************/
do_action('bbp_new_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, false, $reply_to);
/** Additional Actions (After Save) ***********************************/
do_action('bbp_new_reply_post_extras', $reply_id);
/** Redirect **********************************************************/
// Redirect to
$redirect_to = bbp_get_redirect_to();
// Get the reply URL
$reply_url = bbp_get_reply_url($reply_id, $redirect_to);
// Allow to be filtered
$reply_url = apply_filters('bbp_new_reply_redirect_to', $reply_url, $redirect_to, $reply_id);
/** Successful Save ***************************************************/
// Redirect back to new reply
wp_safe_redirect($reply_url);
// For good measure
exit;
/** Errors ****************************************************************/
} else {
$append_error = is_wp_error($reply_id) && $reply_id->get_error_message() ? $reply_id->get_error_message() . ' ' : '';
bbp_add_error('bbp_reply_error', __('<strong>ERROR</strong>: The following problem(s) have been found with your reply:' . $append_error . 'Please try again.', 'bbpress'));
}
}
示例4: bbp_toggle_topic_handler
/**
* Handles the front end opening/closing, spamming/unspamming,
* sticking/unsticking and trashing/untrashing/deleting of topics
*
* @since bbPress (r2727)
*
* @param string $action The requested action to compare this function to
* @uses bbp_get_topic() To get the topic
* @uses current_user_can() To check if the user is capable of editing or
* deleting the topic
* @uses bbp_get_topic_post_type() To get the topic post type
* @uses check_ajax_referer() To verify the nonce and check the referer
* @uses bbp_is_topic_open() To check if the topic is open
* @uses bbp_close_topic() To close the topic
* @uses bbp_open_topic() To open the topic
* @uses bbp_is_topic_sticky() To check if the topic is a sticky
* @uses bbp_unstick_topic() To unstick the topic
* @uses bbp_stick_topic() To stick the topic
* @uses bbp_is_topic_spam() To check if the topic is marked as spam
* @uses bbp_spam_topic() To make the topic as spam
* @uses bbp_unspam_topic() To unmark the topic as spam
* @uses wp_trash_post() To trash the topic
* @uses wp_untrash_post() To untrash the topic
* @uses wp_delete_post() To delete the topic
* @uses do_action() Calls 'bbp_toggle_topic_handler' with success, post data
* and action
* @uses bbp_get_forum_permalink() To get the forum link
* @uses bbp_get_topic_permalink() To get the topic link
* @uses wp_safe_redirect() To redirect to the topic
* @uses bbPress::errors:add() To log the error messages
*/
function bbp_toggle_topic_handler($action = '')
{
// Bail if required GET actions aren't passed
if (empty($_GET['topic_id'])) {
return;
}
// Setup possible get actions
$possible_actions = array('bbp_toggle_topic_close', 'bbp_toggle_topic_stick', 'bbp_toggle_topic_spam', 'bbp_toggle_topic_trash');
// Bail if actions aren't meant for this function
if (!in_array($action, $possible_actions)) {
return;
}
$failure = '';
// Empty failure string
$view_all = false;
// Assume not viewing all
$topic_id = (int) $_GET['topic_id'];
// What's the topic id?
$success = false;
// Flag
$post_data = array('ID' => $topic_id);
// Prelim array
$redirect = '';
// Empty redirect URL
// Make sure topic exists
$topic = bbp_get_topic($topic_id);
if (empty($topic)) {
return;
}
// What is the user doing here?
if (!current_user_can('edit_topic', $topic->ID) || 'bbp_toggle_topic_trash' === $action && !current_user_can('delete_topic', $topic->ID)) {
bbp_add_error('bbp_toggle_topic_permission', __('<strong>ERROR:</strong> You do not have the permission to do that.', 'bbpress'));
return;
}
// What action are we trying to perform?
switch ($action) {
// Toggle open/close
case 'bbp_toggle_topic_close':
check_ajax_referer('close-topic_' . $topic_id);
$is_open = bbp_is_topic_open($topic_id);
$success = true === $is_open ? bbp_close_topic($topic_id) : bbp_open_topic($topic_id);
$failure = true === $is_open ? __('<strong>ERROR</strong>: There was a problem closing the topic.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem opening the topic.', 'bbpress');
break;
// Toggle sticky/super-sticky/unstick
// Toggle sticky/super-sticky/unstick
case 'bbp_toggle_topic_stick':
check_ajax_referer('stick-topic_' . $topic_id);
$is_sticky = bbp_is_topic_sticky($topic_id);
$is_super = false === $is_sticky && !empty($_GET['super']) && "1" === $_GET['super'] ? true : false;
$success = true === $is_sticky ? bbp_unstick_topic($topic_id) : bbp_stick_topic($topic_id, $is_super);
$failure = true === $is_sticky ? __('<strong>ERROR</strong>: There was a problem unsticking the topic.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem sticking the topic.', 'bbpress');
break;
// Toggle spam
// Toggle spam
case 'bbp_toggle_topic_spam':
check_ajax_referer('spam-topic_' . $topic_id);
$is_spam = bbp_is_topic_spam($topic_id);
$success = true === $is_spam ? bbp_unspam_topic($topic_id) : bbp_spam_topic($topic_id);
$failure = true === $is_spam ? __('<strong>ERROR</strong>: There was a problem unmarking the topic as spam.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem marking the topic as spam.', 'bbpress');
$view_all = !$is_spam;
break;
// Toggle trash
// Toggle trash
case 'bbp_toggle_topic_trash':
$sub_action = !empty($_GET['sub_action']) && in_array($_GET['sub_action'], array('trash', 'untrash', 'delete')) ? $_GET['sub_action'] : false;
if (empty($sub_action)) {
break;
}
switch ($sub_action) {
//.........这里部分代码省略.........
示例5: row_actions
/**
* Topic Row actions
*
* Remove the quick-edit action link under the topic title and add the
* content and close/stick/spam links
*
* @since 2.0.0 bbPress (r2485)
*
* @param array $actions Actions
* @param array $topic Topic object
* @uses bbp_get_topic_post_type() To get the topic post type
* @uses bbp_topic_content() To output topic content
* @uses bbp_get_topic_permalink() To get the topic link
* @uses bbp_get_topic_title() To get the topic title
* @uses current_user_can() To check if the current user can edit or
* delete the topic
* @uses bbp_is_topic_open() To check if the topic is open
* @uses bbp_is_topic_spam() To check if the topic is marked as spam
* @uses bbp_is_topic_sticky() To check if the topic is a sticky or a
* super sticky
* @uses get_post_type_object() To get the topic post type object
* @uses add_query_arg() To add custom args to the url
* @uses remove_query_arg() To remove custom args from the url
* @uses wp_nonce_url() To nonce the url
* @uses get_delete_post_link() To get the delete post link of the topic
* @return array $actions Actions
*/
public function row_actions($actions, $topic)
{
if ($this->bail()) {
return $actions;
}
unset($actions['inline hide-if-no-js']);
// Show view link if it's not set, the topic is trashed and the user can view trashed topics
if (empty($actions['view']) && bbp_get_trash_status_id() === $topic->post_status && current_user_can('view_trash')) {
$actions['view'] = '<a href="' . esc_url(bbp_get_topic_permalink($topic->ID)) . '" title="' . esc_attr(sprintf(__('View “%s”', 'bbpress'), bbp_get_topic_title($topic->ID))) . '" rel="permalink">' . esc_html__('View', 'bbpress') . '</a>';
}
// Only show the actions if the user is capable of viewing them :)
if (current_user_can('moderate', $topic->ID)) {
// Pending
// Show the 'approve' and 'view' link on pending posts only and 'unapprove' on published posts only
$approve_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_approve'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'approve-topic_' . $topic->ID);
if (bbp_is_topic_published($topic->ID)) {
$actions['unapproved'] = '<a href="' . esc_url($approve_uri) . '" title="' . esc_attr__('Unapprove this topic', 'bbpress') . '">' . _x('Unapprove', 'Unapprove Topic', 'bbpress') . '</a>';
} elseif (!bbp_is_topic_private($topic->ID)) {
$actions['approved'] = '<a href="' . esc_url($approve_uri) . '" title="' . esc_attr__('Approve this topic', 'bbpress') . '">' . _x('Approve', 'Approve Topic', 'bbpress') . '</a>';
$actions['view'] = '<a href="' . esc_url(bbp_get_topic_permalink($topic->ID)) . '" title="' . esc_attr(sprintf(__('View “%s”', 'bbpress'), bbp_get_topic_title($topic->ID))) . '" rel="permalink">' . esc_html__('View', 'bbpress') . '</a>';
}
// Close
// Show the 'close' and 'open' link on published and closed posts only
if (in_array($topic->post_status, array(bbp_get_public_status_id(), bbp_get_closed_status_id()))) {
$close_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_close'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'close-topic_' . $topic->ID);
if (bbp_is_topic_open($topic->ID)) {
$actions['closed'] = '<a href="' . esc_url($close_uri) . '" title="' . esc_attr__('Close this topic', 'bbpress') . '">' . _x('Close', 'Close a Topic', 'bbpress') . '</a>';
} else {
$actions['closed'] = '<a href="' . esc_url($close_uri) . '" title="' . esc_attr__('Open this topic', 'bbpress') . '">' . _x('Open', 'Open a Topic', 'bbpress') . '</a>';
}
}
// Sticky
// Dont show sticky if topic links is spam, trash or pending
if (!bbp_is_topic_spam($topic->ID) && !bbp_is_topic_trash($topic->ID) && !bbp_is_topic_pending($topic->ID)) {
$stick_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'stick-topic_' . $topic->ID);
if (bbp_is_topic_sticky($topic->ID)) {
$actions['stick'] = '<a href="' . esc_url($stick_uri) . '" title="' . esc_attr__('Unstick this topic', 'bbpress') . '">' . esc_html__('Unstick', 'bbpress') . '</a>';
} else {
$super_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick', 'super' => '1'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'stick-topic_' . $topic->ID);
$actions['stick'] = '<a href="' . esc_url($stick_uri) . '" title="' . esc_attr__('Stick this topic to its forum', 'bbpress') . '">' . esc_html__('Stick', 'bbpress') . '</a> <a href="' . esc_url($super_uri) . '" title="' . esc_attr__('Stick this topic to front', 'bbpress') . '">' . esc_html__('(to front)', 'bbpress') . '</a>';
}
}
// Spam
$spam_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_spam'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'spam-topic_' . $topic->ID);
if (bbp_is_topic_spam($topic->ID)) {
$actions['spam'] = '<a href="' . esc_url($spam_uri) . '" title="' . esc_attr__('Mark the topic as not spam', 'bbpress') . '">' . esc_html__('Not spam', 'bbpress') . '</a>';
} else {
$actions['spam'] = '<a href="' . esc_url($spam_uri) . '" title="' . esc_attr__('Mark this topic as spam', 'bbpress') . '">' . esc_html__('Spam', 'bbpress') . '</a>';
}
}
// Do not show trash links for spam topics, or spam links for trashed topics
if (current_user_can('delete_topic', $topic->ID)) {
if (bbp_get_trash_status_id() === $topic->post_status) {
$post_type_object = get_post_type_object(bbp_get_topic_post_type());
$actions['untrash'] = "<a title='" . esc_attr__('Restore this item from the Trash', 'bbpress') . "' href='" . wp_nonce_url(add_query_arg(array('_wp_http_referer' => add_query_arg(array('post_type' => bbp_get_topic_post_type()), admin_url('edit.php'))), admin_url(sprintf($post_type_object->_edit_link . '&action=untrash', $topic->ID))), 'untrash-' . $topic->post_type . '_' . $topic->ID) . "'>" . esc_html__('Restore', 'bbpress') . "</a>";
} elseif (EMPTY_TRASH_DAYS) {
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr__('Move this item to the Trash', 'bbpress') . "' href='" . esc_url(add_query_arg(array('_wp_http_referer' => add_query_arg(array('post_type' => bbp_get_topic_post_type()), admin_url('edit.php'))), get_delete_post_link($topic->ID))) . "'>" . esc_html__('Trash', 'bbpress') . "</a>";
}
if (bbp_get_trash_status_id() === $topic->post_status || !EMPTY_TRASH_DAYS) {
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr__('Delete this item permanently', 'bbpress') . "' href='" . esc_url(add_query_arg(array('_wp_http_referer' => add_query_arg(array('post_type' => bbp_get_topic_post_type()), admin_url('edit.php'))), get_delete_post_link($topic->ID, '', true))) . "'>" . esc_html__('Delete Permanently', 'bbpress') . "</a>";
} elseif (bbp_get_spam_status_id() === $topic->post_status) {
unset($actions['trash']);
}
}
return $actions;
}
示例6: bbp_get_form_topic_tags
/**
* Return value of topic tags field
*
* @since bbPress (r2976)
*
* @uses bbp_is_topic_edit() To check if it's the topic edit page
* @uses apply_filters() Calls 'bbp_get_form_topic_tags' with the tags
* @return string Value of topic tags field
*/
function bbp_get_form_topic_tags()
{
// Get _POST data
if (bbp_is_post_request() && isset($_POST['bbp_topic_tags'])) {
$topic_tags = $_POST['bbp_topic_tags'];
// Get edit data
} elseif (bbp_is_single_topic() || bbp_is_single_reply() || bbp_is_topic_edit() || bbp_is_reply_edit()) {
// Determine the topic id based on the post type
switch (get_post_type()) {
// Post is a topic
case bbp_get_topic_post_type():
$topic_id = get_the_ID();
break;
// Post is a reply
// Post is a reply
case bbp_get_reply_post_type():
$topic_id = bbp_get_reply_topic_id(get_the_ID());
break;
}
// Topic exists
if (!empty($topic_id)) {
// Topic is spammed so display pre-spam terms
if (bbp_is_topic_spam($topic_id)) {
// Get pre-spam terms
$new_terms = get_post_meta($topic_id, '_bbp_spam_topic_tags', true);
// If terms exist, explode them and compile the return value
if (empty($new_terms)) {
$new_terms = '';
}
// Topic is not spam so get real terms
} else {
$terms = array_filter((array) get_the_terms($topic_id, bbp_get_topic_tag_tax_id()));
// Loop through them
foreach ($terms as $term) {
$new_terms[] = $term->name;
}
}
// Define local variable(s)
} else {
$new_terms = '';
}
// Set the return value
$topic_tags = !empty($new_terms) ? implode(', ', $new_terms) : '';
// No data
} else {
$topic_tags = '';
}
return apply_filters('bbp_get_form_topic_tags', esc_attr($topic_tags));
}
示例7: bbp_toggle_topic
/**
* Do the actual topic toggling
*
* This function is used by `bbp_toggle_topic_handler()` to do the actual heavy
* lifting when it comes to toggling topic. It only really makes sense to call
* within that context, so if you need to call this function directly, make sure
* you're also doing what the handler does too.
*
* @since 2.6.0 bbPress (r6133)
* @access private
*
* @param array $args
*/
function bbp_toggle_topic($args = array())
{
// Parse the arguments
$r = bbp_parse_args($args, array('id' => 0, 'action' => '', 'sub_action' => '', 'data' => array()));
// Build the nonce suffix
$nonce_suffix = bbp_get_topic_post_type() . '_' . (int) $r['id'];
// Default return values
$retval = array('status' => 0, 'message' => '', 'redirect_to' => bbp_get_topic_permalink($r['id'], bbp_get_redirect_to()), 'view_all' => false);
// What action are we trying to perform?
switch ($r['action']) {
// Toggle approve/unapprove
case 'bbp_toggle_topic_approve':
check_ajax_referer("approve-{$nonce_suffix}");
$is_pending = bbp_is_topic_pending($r['id']);
$retval['view_all'] = !$is_pending;
// Toggle
$retval['status'] = true === $is_pending ? bbp_approve_topic($r['id']) : bbp_unapprove_topic($r['id']);
// Feedback
$retval['message'] = true === $is_pending ? __('<strong>ERROR</strong>: There was a problem approving the topic.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem unapproving the topic.', 'bbpress');
break;
// Toggle open/close
// Toggle open/close
case 'bbp_toggle_topic_close':
check_ajax_referer("close-{$nonce_suffix}");
$is_open = bbp_is_topic_open($r['id']);
// Toggle
$retval['status'] = true === $is_open ? bbp_close_topic($r['id']) : bbp_open_topic($r['id']);
// Feedback
$retval['message'] = true === $is_open ? __('<strong>ERROR</strong>: There was a problem closing the topic.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem opening the topic.', 'bbpress');
break;
// Toggle sticky/super-sticky/unstick
// Toggle sticky/super-sticky/unstick
case 'bbp_toggle_topic_stick':
check_ajax_referer("stick-{$nonce_suffix}");
$is_sticky = bbp_is_topic_sticky($r['id']);
$is_super = false === $is_sticky && !empty($_GET['super']) && "1" === $_GET['super'] ? true : false;
// Toggle
$retval['status'] = true === $is_sticky ? bbp_unstick_topic($r['id']) : bbp_stick_topic($r['id'], $is_super);
// Feedback
$retval['message'] = true === $is_sticky ? __('<strong>ERROR</strong>: There was a problem unsticking the topic.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem sticking the topic.', 'bbpress');
break;
// Toggle spam
// Toggle spam
case 'bbp_toggle_topic_spam':
check_ajax_referer("spam-{$nonce_suffix}");
$is_spam = bbp_is_topic_spam($r['id']);
$retval['view_all'] = !$is_spam;
// Toggle
$retval['status'] = true === $is_spam ? bbp_unspam_topic($r['id']) : bbp_spam_topic($r['id']);
// Feedback
$retval['message'] = true === $is_spam ? __('<strong>ERROR</strong>: There was a problem unmarking the topic as spam.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem marking the topic as spam.', 'bbpress');
break;
// Toggle trash
// Toggle trash
case 'bbp_toggle_topic_trash':
switch ($r['sub_action']) {
case 'trash':
check_ajax_referer("trash-{$nonce_suffix}");
$retval['view_all'] = true;
$retval['status'] = wp_trash_post($r['id']);
$retval['message'] = __('<strong>ERROR</strong>: There was a problem trashing the topic.', 'bbpress');
break;
case 'untrash':
check_ajax_referer("untrash-{$nonce_suffix}");
$retval['status'] = wp_untrash_post($r['id']);
$retval['message'] = __('<strong>ERROR</strong>: There was a problem untrashing the topic.', 'bbpress');
break;
case 'delete':
check_ajax_referer("delete-{$nonce_suffix}");
$retval['status'] = wp_delete_post($r['id']);
$retval['message'] = __('<strong>ERROR</strong>: There was a problem deleting the topic.', 'bbpress');
break;
}
break;
}
// Maybe redirect back to the topic's forum
if (isset($r['sub_action']) && 'delete' === $r['sub_action']) {
$retval['redirect_to'] = bbp_get_forum_permalink($retval['status']->post_parent);
}
// Add view all if needed
if (!empty($retval['view_all'])) {
$retval['redirect_to'] = bbp_add_view_all($retval['redirect_to'], true);
}
// Filter & return
return apply_filters('bbp_toggle_topic', $retval, $r, $args);
}
示例8: if
<?php if ( ! ( bbp_use_wp_editor() || current_user_can( 'unfiltered_html' ) ) ) : ?>
<p class="form-allowed-tags">
<label><?php _e( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes:','bbpress' ); ?></label><br />
<code><?php bbp_allowed_tags(); ?></code>
</p>
<?php endif; ?>
<?php if ( bbp_allow_topic_tags() && current_user_can( 'assign_topic_tags' ) ) : ?>
<?php do_action( 'bbp_theme_before_reply_form_tags' ); ?>
<p>
<label for="bbp_topic_tags"><?php _e( 'Tags:', 'bbpress' ); ?></label><br />
<input type="text" value="<?php bbp_form_topic_tags(); ?>" tabindex="<?php bbp_tab_index(); ?>" size="40" name="bbp_topic_tags" id="bbp_topic_tags" <?php disabled( bbp_is_topic_spam() ); ?> />
</p>
<?php do_action( 'bbp_theme_after_reply_form_tags' ); ?>
<?php endif; ?>
<?php if ( bbp_is_subscriptions_active() && !bbp_is_anonymous() && ( !bbp_is_reply_edit() || ( bbp_is_reply_edit() && !bbp_is_reply_anonymous() ) ) ) : ?>
<?php do_action( 'bbp_theme_before_reply_form_subscription' ); ?>
<p>
<input name="bbp_topic_subscription" id="bbp_topic_subscription" type="checkbox" value="bbp_subscribe"<?php bbp_form_topic_subscribed(); ?> tabindex="<?php bbp_tab_index(); ?>" />
<?php if ( bbp_is_reply_edit() && ( bbp_get_reply_author_id() !== bbp_get_current_user_id() ) ) : ?>
示例9: bbp_new_reply_handler
//.........这里部分代码省略.........
$reply_title = apply_filters('bbp_new_reply_pre_title', $reply_title);
// No reply title
if (empty($reply_title)) {
bbp_add_error('bbp_reply_title', __('<strong>ERROR</strong>: Your reply needs a title.', 'bbpress'));
}
/** Reply Content *********************************************************/
if (!empty($_POST['bbp_reply_content'])) {
$reply_content = $_POST['bbp_reply_content'];
}
// Filter and sanitize
$reply_content = apply_filters('bbp_new_reply_pre_content', $reply_content);
// No reply content
if (empty($reply_content)) {
bbp_add_error('bbp_reply_content', __('<strong>ERROR</strong>: Your reply cannot be empty.', 'bbpress'));
}
/** Reply Flooding ********************************************************/
if (!bbp_check_for_flood($anonymous_data, $reply_author)) {
bbp_add_error('bbp_reply_flood', __('<strong>ERROR</strong>: Slow down; you move too fast.', 'bbpress'));
}
/** Reply Duplicate *******************************************************/
if (!bbp_check_for_duplicate(array('post_type' => bbp_get_reply_post_type(), 'post_author' => $reply_author, 'post_content' => $reply_content, 'post_parent' => $topic_id, 'anonymous_data' => $anonymous_data))) {
bbp_add_error('bbp_reply_duplicate', __('<strong>ERROR</strong>: Duplicate reply detected; it looks as though you’ve already said that!', 'bbpress'));
}
/** Reply Blacklist *******************************************************/
if (!bbp_check_for_blacklist($anonymous_data, $reply_author, $reply_title, $reply_content)) {
bbp_add_error('bbp_reply_blacklist', __('<strong>ERROR</strong>: Your reply cannot be created at this time.', 'bbpress'));
}
/** Reply Moderation ******************************************************/
$post_status = bbp_get_public_status_id();
if (!bbp_check_for_moderation($anonymous_data, $reply_author, $reply_title, $reply_content)) {
$post_status = bbp_get_pending_status_id();
}
/** Topic Tags ************************************************************/
if (!empty($_POST['bbp_topic_tags'])) {
$terms = esc_attr(strip_tags($_POST['bbp_topic_tags']));
}
/** Additional Actions (Before Save) **************************************/
do_action('bbp_new_reply_pre_extras', $topic_id, $forum_id);
// Bail if errors
if (bbp_has_errors()) {
return;
}
/** No Errors *************************************************************/
// Add the content of the form to $reply_data as an array
// Just in time manipulation of reply data before being created
$reply_data = apply_filters('bbp_new_reply_pre_insert', array('post_author' => $reply_author, 'post_title' => $reply_title, 'post_content' => $reply_content, 'post_parent' => $topic_id, 'post_status' => $post_status, 'post_type' => bbp_get_reply_post_type(), 'comment_status' => 'closed', 'menu_order' => (int) (bbp_get_topic_reply_count($topic_id) + 1)));
// Insert reply
$reply_id = wp_insert_post($reply_data);
/** No Errors *************************************************************/
// Check for missing reply_id or error
if (!empty($reply_id) && !is_wp_error($reply_id)) {
/** Topic Tags ********************************************************/
// Just in time manipulation of reply terms before being edited
$terms = apply_filters('bbp_new_reply_pre_set_terms', $terms, $topic_id, $reply_id);
// Insert terms
$terms = wp_set_post_terms($topic_id, $terms, bbp_get_topic_tag_tax_id(), false);
// Term error
if (is_wp_error($terms)) {
bbp_add_error('bbp_reply_tags', __('<strong>ERROR</strong>: There was a problem adding the tags to the topic.', 'bbpress'));
}
/** Trash Check *******************************************************/
// If this reply starts as trash, add it to pre_trashed_replies
// for the topic, so it is properly restored.
if (bbp_is_topic_trash($topic_id) || $reply_data['post_status'] == bbp_get_trash_status_id()) {
// Trash the reply
wp_trash_post($reply_id);
// Get pre_trashed_replies for topic
$pre_trashed_replies = get_post_meta($topic_id, '_bbp_pre_trashed_replies', true);
// Add this reply to the end of the existing replies
$pre_trashed_replies[] = $reply_id;
// Update the pre_trashed_reply post meta
update_post_meta($topic_id, '_bbp_pre_trashed_replies', $pre_trashed_replies);
}
/** Spam Check ********************************************************/
// If reply or topic are spam, officially spam this reply
if (bbp_is_topic_spam($topic_id) || $reply_data['post_status'] == bbp_get_spam_status_id()) {
add_post_meta($reply_id, '_bbp_spam_meta_status', bbp_get_public_status_id());
}
/** Update counts, etc... *********************************************/
do_action('bbp_new_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author);
/** Additional Actions (After Save) ***********************************/
do_action('bbp_new_reply_post_extras', $reply_id);
/** Redirect **********************************************************/
// Redirect to
$redirect_to = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '';
// Get the reply URL
$reply_url = bbp_get_reply_url($reply_id, $redirect_to);
// Allow to be filtered
$reply_url = apply_filters('bbp_new_reply_redirect_to', $reply_url, $redirect_to, $reply_id);
/** Successful Save ***************************************************/
// Redirect back to new reply
wp_safe_redirect($reply_url);
// For good measure
exit;
/** Errors ****************************************************************/
} else {
$append_error = is_wp_error($reply_id) && $reply_id->get_error_message() ? $reply_id->get_error_message() . ' ' : '';
bbp_add_error('bbp_reply_error', __('<strong>ERROR</strong>: The following problem(s) have been found with your reply:' . $append_error . 'Please try again.', 'bbpress'));
}
}
示例10: post
//.........这里部分代码省略.........
if (user_can($user_id, 'unfiltered_html')) {
remove_filter('bbp_new_reply_pre_title', 'wp_filter_kses');
remove_filter('bbp_new_reply_pre_content', 'wp_filter_kses');
}
/** REPLY DATA ***************************************************/
// setup a dummy reply title b/c bbP requires it
$reply_title = sprintf(__('Reply To: Topic ID %d', 'bp-rbe'), $topic_id);
// Filter and sanitize
$reply_content = apply_filters('bbp_new_reply_pre_content', $data['content']);
/** REPLY MODERATION *********************************************/
// Reply Flooding
if (!bbp_check_for_flood($anonymous_data, $reply_author)) {
//do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_reply_flood' );
//bbp_add_error( 'bbp_reply_flood', __( '<strong>ERROR</strong>: Slow down; you move too fast.', 'bbpress' ) );
return new WP_Error('bbp_reply_flood', '', $data);
}
// Reply Duplicate
if (!bbp_check_for_duplicate(array('post_type' => bbp_get_reply_post_type(), 'post_author' => $reply_author, 'post_content' => $reply_content, 'post_parent' => $topic_id, 'anonymous_data' => $anonymous_data))) {
//do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_reply_duplicate' );
return new WP_Error('bbp_reply_duplicate', '', $data);
}
// Reply Blacklist
if (!bbp_check_for_blacklist($anonymous_data, $reply_author, $reply_title, $reply_content)) {
//do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_reply_blacklist' );
return new WP_Error('bbp_reply_blacklist', '', $data);
}
// Reply Status
// Maybe put into moderation
if (!bbp_check_for_moderation($anonymous_data, $reply_author, $reply_title, $reply_content)) {
$reply_status = bbp_get_pending_status_id();
// Default
} else {
$reply_status = bbp_get_public_status_id();
}
/** POSTING TIME! ************************************************/
// get forum ID
$forum_id = bbp_get_topic_forum_id($topic_id);
// bbP hook before save
do_action('bbp_new_reply_pre_extras', $topic_id, $forum_id);
// Setup reply data
$reply_data = apply_filters('bbp_new_reply_pre_insert', array('post_author' => $reply_author, 'post_title' => $reply_title, 'post_content' => $reply_content, 'post_status' => $reply_status, 'post_parent' => $topic_id, 'post_type' => bbp_get_reply_post_type(), 'comment_status' => 'closed', 'menu_order' => bbp_get_topic_reply_count($topic_id, false) + 1));
// Insert reply
$reply_id = wp_insert_post($reply_data);
// Reply posted!
if (!is_wp_error($reply_id)) {
// more internal logging
bp_rbe_log('Message #' . $i . ': bbPress reply successfully posted!');
// Problem posting
} else {
//do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_reply_error' );
return new WP_Error('bbp_reply_error', '', $data);
}
/** AFTER POSTING ************************************************/
// stuff that needs to happen after a bbP reply is posted occurs here... bbP
// should preferably do the following at the 'bbp_new_reply' hook, until then
// do what bbP does inline.
// Trash Check ////////////////////////////////////////////////////
// If this reply starts as trash, add it to pre_trashed_replies
// for the topic, so it is properly restored.
if (bbp_is_topic_trash($topic_id) || $reply_data['post_status'] == bbp_get_trash_status_id()) {
// Trash the reply
wp_trash_post($reply_id);
// Only add to pre-trashed array if topic is trashed
if (bbp_is_topic_trash($topic_id)) {
// Get pre_trashed_replies for topic
$pre_trashed_replies = get_post_meta($topic_id, '_bbp_pre_trashed_replies', true);
// Add this reply to the end of the existing replies
$pre_trashed_replies[] = $reply_id;
// Update the pre_trashed_reply post meta
update_post_meta($topic_id, '_bbp_pre_trashed_replies', $pre_trashed_replies);
}
// Spam Check /////////////////////////////////////////////////////
// If reply or topic are spam, officially spam this reply
} elseif (bbp_is_topic_spam($topic_id) || $reply_data['post_status'] == bbp_get_spam_status_id()) {
add_post_meta($reply_id, '_bbp_spam_meta_status', bbp_get_public_status_id());
// Only add to pre-spammed array if topic is spam
if (bbp_is_topic_spam($topic_id)) {
// Get pre_spammed_replies for topic
$pre_spammed_replies = get_post_meta($topic_id, '_bbp_pre_spammed_replies', true);
// Add this reply to the end of the existing replies
$pre_spammed_replies[] = $reply_id;
// Update the pre_spammed_replies post meta
update_post_meta($topic_id, '_bbp_pre_spammed_replies', $pre_spammed_replies);
}
}
// Reply By Email /////////////////////////////////////////////////
// Add a RBE marker to the post's meta
// Could potentially show that post was made via email on the frontend
add_post_meta($reply_id, 'bp_rbe', 1);
/** POST HOOKS ***************************************************/
// RBE Custom Hooks ///////////////////////////////////////////////
// change activity action
add_filter('bbp_before_record_activity_parse_args', array($this, 'change_activity_action'));
// add RBE's special activity hook
add_action('bp_activity_after_save', array($this, 'activity_rbe_hook'));
// bbPress Reply Hooks ////////////////////////////////////////////
do_action('bbp_new_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, false, $reply_to);
do_action('bbp_new_reply_post_extras', $reply_id);
return array('bbp_reply_id' => $reply_id);
}
示例11: post_row_actions
/**
* Add a Spam row action
*
* @param unknown_type $actions
* @param unknown_type $post
*/
function post_row_actions($actions, $post)
{
global $wpdb;
$the_id = $post->ID;
// For replies:
if ($post->post_type == 'reply' && $post->post_status == 'pending' && !array_key_exists('spam', $actions)) {
// Mark posts as spam
$spam_uri = esc_url(wp_nonce_url(add_query_arg(array('reply_id' => $the_id, 'action' => 'bbp_toggle_reply_spam'), remove_query_arg(array('bbp_reply_toggle_notice', 'reply_id', 'failed', 'super'))), 'spam-reply_' . $the_id));
if (bbp_is_reply_spam($the_id)) {
$actions['spam'] = '<a href="' . $spam_uri . '" title="' . esc_attr__('Mark the reply as not spam', 'bbpress') . '">' . __('Not spam', 'bbpress') . '</a>';
} else {
$actions['spam'] = '<a href="' . $spam_uri . '" title="' . esc_attr__('Mark this reply as spam', 'bbpress') . '">' . __('Spam', 'bbpress') . '</a>';
}
}
// For Topics:
if ($post->post_type == 'topic' && $post->post_status == 'pending' && !array_key_exists('spam', $actions)) {
// Mark posts as spam
$spam_uri = esc_url(wp_nonce_url(add_query_arg(array('topic_id' => $the_id, 'action' => 'bbp_toggle_topic_spam'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'spam-topic_' . $the_id));
if (bbp_is_topic_spam($the_id)) {
$actions['spam'] = '<a href="' . $spam_uri . '" title="' . esc_attr__('Mark the topic as not spam', 'bbpress') . '">' . __('Not spam', 'bbpress') . '</a>';
} else {
$actions['spam'] = '<a href="' . $spam_uri . '" title="' . esc_attr__('Mark this topic as spam', 'bbpress') . '">' . __('Spam', 'bbpress') . '</a>';
}
}
return $actions;
}