本文整理汇总了PHP中bbp_get_topic_tag_tax_id函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_get_topic_tag_tax_id函数的具体用法?PHP bbp_get_topic_tag_tax_id怎么用?PHP bbp_get_topic_tag_tax_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_get_topic_tag_tax_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bbp_edit_reply_handler
//.........这里部分代码省略.........
bbp_add_error('bbp_edit_reply_content', __('<strong>ERROR</strong>: Your reply cannot be empty.', '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 edited at this time.', 'bbpress'));
}
/** Reply Status **********************************************************/
// Maybe put into moderation
if (!bbp_check_for_moderation($anonymous_data, $reply_author, $reply_title, $reply_content)) {
// Set post status to pending if public
if (bbp_get_public_status_id() === $reply->post_status) {
$reply_status = bbp_get_pending_status_id();
}
// Use existing post_status
} else {
$reply_status = $reply->post_status;
}
/** 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 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_edit_reply_pre_extras', $reply_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 edited
$reply_data = apply_filters('bbp_edit_reply_pre_insert', array('ID' => $reply_id, 'post_title' => $reply_title, 'post_content' => $reply_content, 'post_status' => $reply_status, 'post_parent' => $topic_id, 'post_author' => $reply_author, 'post_type' => bbp_get_reply_post_type()));
// Toggle revisions to avoid duplicates
if (post_type_supports(bbp_get_reply_post_type(), 'revisions')) {
$revisions_removed = true;
remove_post_type_support(bbp_get_reply_post_type(), 'revisions');
}
// Insert topic
$reply_id = wp_update_post($reply_data);
// Toggle revisions back on
if (true === $revisions_removed) {
$revisions_removed = false;
add_post_type_support(bbp_get_reply_post_type(), 'revisions');
}
/** Topic Tags ************************************************************/
// Just in time manipulation of reply terms before being edited
$terms = apply_filters('bbp_edit_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'));
}
/** Revisions *************************************************************/
// Revision Reason
if (!empty($_POST['bbp_reply_edit_reason'])) {
$reply_edit_reason = esc_attr(strip_tags($_POST['bbp_reply_edit_reason']));
}
// Update revision log
if (!empty($_POST['bbp_log_reply_edit']) && "1" === $_POST['bbp_log_reply_edit']) {
$revision_id = wp_save_post_revision($reply_id);
if (!empty($revision_id)) {
bbp_update_reply_revision_log(array('reply_id' => $reply_id, 'revision_id' => $revision_id, 'author_id' => bbp_get_current_user_id(), 'reason' => $reply_edit_reason));
}
}
/** No Errors *************************************************************/
if (!empty($reply_id) && !is_wp_error($reply_id)) {
// Update counts, etc...
do_action('bbp_edit_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, true, $reply_to);
/** Additional Actions (After Save) ***********************************/
do_action('bbp_edit_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_edit_reply_redirect_to', $reply_url, $redirect_to);
/** Successful Edit ***************************************************/
// 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'));
}
}
示例2: bbp_get_breadcrumb
//.........这里部分代码省略.........
$pre_current_text = bbp_get_reply_title();
// Topic Tag (or theme compat topic tag)
} elseif (bbp_is_topic_tag() || get_query_var('bbp_topic_tag') && !bbp_is_topic_tag_edit()) {
// Always include the tag name
$tag_data[] = bbp_get_topic_tag_name();
// If capable, include a link to edit the tag
if (current_user_can('manage_topic_tags')) {
$tag_data[] = '<a href="' . bbp_get_topic_tag_edit_link() . '" class="bbp-edit-topic-tag-link">' . __('(Edit)', 'bbpress') . '</a>';
}
// Implode the results of the tag data
$pre_current_text = sprintf(__('Topic Tag: %s', 'bbpress'), implode(' ', $tag_data));
// Edit Topic Tag
} elseif (bbp_is_topic_tag_edit()) {
$pre_current_text = __('Edit', 'bbpress');
// Single
} else {
$pre_current_text = get_the_title();
}
/** Parse Args ********************************************************/
// Parse args
$defaults = array('before' => '<div class="bbp-breadcrumb"><p>', 'after' => '</p></div>', 'sep' => __('›', 'bbpress'), 'pad_sep' => 1, 'include_home' => $pre_include_home, 'home_text' => $pre_front_text, 'include_root' => $pre_include_root, 'root_text' => $pre_root_text, 'include_current' => $pre_include_current, 'current_text' => $pre_current_text);
$r = bbp_parse_args($args, $defaults, 'get_breadcrumb');
extract($r);
/** Ancestors *********************************************************/
// Get post ancestors
if (is_page() || is_single() || bbp_is_forum_edit() || bbp_is_topic_edit() || bbp_is_reply_edit()) {
$ancestors = array_reverse(get_post_ancestors(get_the_ID()));
}
// Do we want to include a link to home?
if (!empty($include_home) || empty($home_text)) {
$crumbs[] = '<a href="' . trailingslashit(home_url()) . '" class="bbp-breadcrumb-home">' . $home_text . '</a>';
}
// Do we want to include a link to the forum root?
if (!empty($include_root) || empty($root_text)) {
// Page exists at root slug path, so use its permalink
$page = bbp_get_page_by_path(bbp_get_root_slug());
if (!empty($page)) {
$root_url = get_permalink($page->ID);
// Use the root slug
} else {
$root_url = get_post_type_archive_link(bbp_get_forum_post_type());
}
// Add the breadcrumb
$crumbs[] = '<a href="' . $root_url . '" class="bbp-breadcrumb-root">' . $root_text . '</a>';
}
// Ancestors exist
if (!empty($ancestors)) {
// Loop through parents
foreach ((array) $ancestors as $parent_id) {
// Parents
$parent = get_post($parent_id);
// Switch through post_type to ensure correct filters are applied
switch ($parent->post_type) {
// Forum
case bbp_get_forum_post_type():
$crumbs[] = '<a href="' . bbp_get_forum_permalink($parent->ID) . '" class="bbp-breadcrumb-forum">' . bbp_get_forum_title($parent->ID) . '</a>';
break;
// Topic
// Topic
case bbp_get_topic_post_type():
$crumbs[] = '<a href="' . bbp_get_topic_permalink($parent->ID) . '" class="bbp-breadcrumb-topic">' . bbp_get_topic_title($parent->ID) . '</a>';
break;
// Reply (Note: not in most themes)
// Reply (Note: not in most themes)
case bbp_get_reply_post_type():
$crumbs[] = '<a href="' . bbp_get_reply_permalink($parent->ID) . '" class="bbp-breadcrumb-reply">' . bbp_get_reply_title($parent->ID) . '</a>';
break;
// WordPress Post/Page/Other
// WordPress Post/Page/Other
default:
$crumbs[] = '<a href="' . get_permalink($parent->ID) . '" class="bbp-breadcrumb-item">' . get_the_title($parent->ID) . '</a>';
break;
}
}
// Edit topic tag
} elseif (bbp_is_topic_tag_edit()) {
$crumbs[] = '<a href="' . get_term_link(bbp_get_topic_tag_id(), bbp_get_topic_tag_tax_id()) . '" class="bbp-breadcrumb-topic-tag">' . sprintf(__('Topic Tag: %s', 'bbpress'), bbp_get_topic_tag_name()) . '</a>';
}
/** Current ***********************************************************/
// Add current page to breadcrumb
if (!empty($include_current) || empty($pre_current_text)) {
$crumbs[] = '<span class="bbp-breadcrumb-current">' . $current_text . '</span>';
}
/** Separator *********************************************************/
// Wrap the separator in a span before padding and filter
if (!empty($sep)) {
$sep = '<span class="bbp-breadcrumb-separator">' . $sep . '</span>';
}
// Pad the separator
if (!empty($pad_sep)) {
$sep = str_pad($sep, strlen($sep) + (int) $pad_sep * 2, ' ', STR_PAD_BOTH);
}
/** Finish Up *********************************************************/
// Filter the separator and breadcrumb
$sep = apply_filters('bbp_breadcrumb_separator', $sep);
$crumbs = apply_filters('bbp_breadcrumbs', $crumbs);
// Build the trail
$trail = !empty($crumbs) ? $before . implode($sep, $crumbs) . $after : '';
return apply_filters('bbp_get_breadcrumb', $trail, $crumbs, $r);
}
示例3: bbp_get_statistics
//.........这里部分代码省略.........
* @return object Walked forum tree
*/
function bbp_get_statistics($args = array())
{
// Parse arguments against default values
$r = bbp_parse_args($args, array('count_users' => true, 'count_forums' => true, 'count_topics' => true, 'count_pending_topics' => true, 'count_private_topics' => true, 'count_spammed_topics' => true, 'count_trashed_topics' => true, 'count_replies' => true, 'count_pending_replies' => true, 'count_private_replies' => true, 'count_spammed_replies' => true, 'count_trashed_replies' => true, 'count_tags' => true, 'count_empty_tags' => true), 'get_statistics');
// Defaults
$user_count = 0;
$forum_count = 0;
$topic_count = 0;
$topic_count_hidden = 0;
$reply_count = 0;
$reply_count_hidden = 0;
$topic_tag_count = 0;
$empty_topic_tag_count = 0;
// Users
if (!empty($r['count_users'])) {
$user_count = bbp_get_total_users();
}
// Forums
if (!empty($r['count_forums'])) {
$forum_count = wp_count_posts(bbp_get_forum_post_type())->publish;
}
// Post statuses
$pending = bbp_get_pending_status_id();
$private = bbp_get_private_status_id();
$spam = bbp_get_spam_status_id();
$trash = bbp_get_trash_status_id();
$closed = bbp_get_closed_status_id();
// Topics
if (!empty($r['count_topics'])) {
$all_topics = wp_count_posts(bbp_get_topic_post_type());
// Published (publish + closed)
$topic_count = $all_topics->publish + $all_topics->{$closed};
if (current_user_can('read_private_topics') || current_user_can('edit_others_topics') || current_user_can('view_trash')) {
// Declare empty arrays
$topics = $topic_titles = array();
// Pending
$topics['pending'] = !empty($r['count_pending_topics']) && current_user_can('edit_others_topics') ? (int) $all_topics->{$pending} : 0;
// Private
$topics['private'] = !empty($r['count_private_topics']) && current_user_can('read_private_topics') ? (int) $all_topics->{$private} : 0;
// Spam
$topics['spammed'] = !empty($r['count_spammed_topics']) && current_user_can('edit_others_topics') ? (int) $all_topics->{$spam} : 0;
// Trash
$topics['trashed'] = !empty($r['count_trashed_topics']) && current_user_can('view_trash') ? (int) $all_topics->{$trash} : 0;
// Total hidden (private + spam + trash)
$topic_count_hidden = $topics['pending'] + $topics['private'] + $topics['spammed'] + $topics['trashed'];
// Generate the hidden topic count's title attribute
$topic_titles[] = !empty($topics['pending']) ? sprintf(__('Pending: %s', 'bbpress'), number_format_i18n($topics['pending'])) : '';
$topic_titles[] = !empty($topics['private']) ? sprintf(__('Private: %s', 'bbpress'), number_format_i18n($topics['private'])) : '';
$topic_titles[] = !empty($topics['spammed']) ? sprintf(__('Spammed: %s', 'bbpress'), number_format_i18n($topics['spammed'])) : '';
$topic_titles[] = !empty($topics['trashed']) ? sprintf(__('Trashed: %s', 'bbpress'), number_format_i18n($topics['trashed'])) : '';
// Compile the hidden topic title
$hidden_topic_title = implode(' | ', array_filter($topic_titles));
}
}
// Replies
if (!empty($r['count_replies'])) {
$all_replies = wp_count_posts(bbp_get_reply_post_type());
// Published
$reply_count = $all_replies->publish;
if (current_user_can('read_private_replies') || current_user_can('edit_others_replies') || current_user_can('view_trash')) {
// Declare empty arrays
$replies = $reply_titles = array();
// Pending
$replies['pending'] = !empty($r['count_pending_replies']) && current_user_can('edit_others_replies') ? (int) $all_replies->{$pending} : 0;
// Private
$replies['private'] = !empty($r['count_private_replies']) && current_user_can('read_private_replies') ? (int) $all_replies->{$private} : 0;
// Spam
$replies['spammed'] = !empty($r['count_spammed_replies']) && current_user_can('edit_others_replies') ? (int) $all_replies->{$spam} : 0;
// Trash
$replies['trashed'] = !empty($r['count_trashed_replies']) && current_user_can('view_trash') ? (int) $all_replies->{$trash} : 0;
// Total hidden (private + spam + trash)
$reply_count_hidden = $replies['pending'] + $replies['private'] + $replies['spammed'] + $replies['trashed'];
// Generate the hidden topic count's title attribute
$reply_titles[] = !empty($replies['pending']) ? sprintf(__('Pending: %s', 'bbpress'), number_format_i18n($replies['pending'])) : '';
$reply_titles[] = !empty($replies['private']) ? sprintf(__('Private: %s', 'bbpress'), number_format_i18n($replies['private'])) : '';
$reply_titles[] = !empty($replies['spammed']) ? sprintf(__('Spammed: %s', 'bbpress'), number_format_i18n($replies['spammed'])) : '';
$reply_titles[] = !empty($replies['trashed']) ? sprintf(__('Trashed: %s', 'bbpress'), number_format_i18n($replies['trashed'])) : '';
// Compile the hidden replies title
$hidden_reply_title = implode(' | ', array_filter($reply_titles));
}
}
// Topic Tags
if (!empty($r['count_tags']) && bbp_allow_topic_tags()) {
// Get the count
$topic_tag_count = wp_count_terms(bbp_get_topic_tag_tax_id(), array('hide_empty' => true));
// Empty tags
if (!empty($r['count_empty_tags']) && current_user_can('edit_topic_tags')) {
$empty_topic_tag_count = wp_count_terms(bbp_get_topic_tag_tax_id()) - $topic_tag_count;
}
}
// Tally the tallies
$statistics = array_map('number_format_i18n', array_map('absint', compact('user_count', 'forum_count', 'topic_count', 'topic_count_hidden', 'reply_count', 'reply_count_hidden', 'topic_tag_count', 'empty_topic_tag_count')));
// Add the hidden (topic/reply) count title attribute strings because we
// don't need to run the math functions on these (see above)
$statistics['hidden_topic_title'] = isset($hidden_topic_title) ? $hidden_topic_title : '';
$statistics['hidden_reply_title'] = isset($hidden_reply_title) ? $hidden_reply_title : '';
return apply_filters('bbp_get_statistics', $statistics, $r);
}
示例4: bbp_unspam_topic
/**
* Unspams a topic
*
* @since bbPress (r2740)
*
* @param int $topic_id Topic id
* @uses wp_get_single_post() To get the topic
* @uses do_action() Calls 'bbp_unspam_topic' with the topic id
* @uses get_post_meta() To get the previous status
* @uses delete_post_meta() To delete the previous status meta
* @uses wp_insert_post() To update the topic with the new status
* @uses do_action() Calls 'bbp_unspammed_topic' with the topic id
* @return mixed False or {@link WP_Error} on failure, topic id on success
*/
function bbp_unspam_topic($topic_id = 0)
{
// Get the topic
if (!($topic = wp_get_single_post($topic_id, ARRAY_A))) {
return $topic;
}
// Bail if already not spam
if (bbp_get_spam_status_id() != $topic['post_status']) {
return false;
}
// Execute pre unspam code
do_action('bbp_unspam_topic', $topic_id);
// Get pre spam status
$topic_status = get_post_meta($topic_id, '_bbp_spam_meta_status', true);
// Set post status to pre spam
$topic['post_status'] = $topic_status;
// Delete pre spam meta
delete_post_meta($topic_id, '_bbp_spam_meta_status');
// No revisions
remove_action('pre_post_update', 'wp_save_post_revision');
// Get pre-spam topic tags
$terms = get_post_meta($topic_id, '_bbp_spam_topic_tags', true);
// Topic had tags before it was spammed
if (!empty($terms)) {
// Set the tax_input of the topic
$topic['tax_input'] = array(bbp_get_topic_tag_tax_id() => $terms);
// Delete pre-spam topic tag meta
delete_post_meta($topic_id, '_bbp_spam_topic_tags');
}
// Update the topic
$topic_id = wp_insert_post($topic);
// Execute post unspam code
do_action('bbp_unspammed_topic', $topic_id);
// Return topic_id
return $topic_id;
}
示例5: process_topic_option
//.........这里部分代码省略.........
return;
}
/**
* The user requested to use a bbPress topic for discussion
*/
if ($create_topic) {
if (!function_exists('bbp_has_forums')) {
?>
<br /><p><?php
_e('bbPress Topics for Posts cannot process this request because it cannot detect your bbPress setup.', 'bbpress-post-topics');
?>
</p><?php
return;
}
$topic_slug = isset($bbppt_options['slug']) ? $bbppt_options['slug'] : '';
$topic_forum = isset($bbppt_options['forum_id']) ? (int) $bbppt_options['forum_id'] : 0;
if (!$use_defaults) {
$topic_display = isset($bbppt_options['display']) ? $bbppt_options['display'] : 'topic';
/** Store extra data for xreplies, as well as any custom display formats */
$topic_display_extras = apply_filters('bbppt_store_display_extras', $bbppt_options['display-extras'], $post);
}
if (!empty($topic_slug)) {
/** if user has selected an existing topic */
if (is_numeric($topic_slug)) {
$topic = bbp_get_topic((int) $topic_slug);
} else {
$topic = bbppt_get_topic_by_slug($topic_slug);
}
if ($topic == null) {
// return an error of some kind
wp_die(__('There was an error with your selected topic.', 'bbpress-post-topics'), __('Error Locating bbPress Topic', 'bbpress-post-topics'));
} else {
$topic_ID = $topic->ID;
update_post_meta($post_ID, 'use_bbpress_discussion_topic', true);
update_post_meta($post_ID, 'bbpress_discussion_topic_id', $topic_ID);
/** Update topic with tags from the post */
if (!empty($bbppt_options['copy_tags'])) {
$post_tags = wp_get_post_tags($post_ID);
$post_tags = array_map(create_function('$term', 'return $term->name;'), $post_tags);
wp_set_post_terms($topic_ID, join(',', $post_tags), bbp_get_topic_tag_tax_id(), true);
update_post_meta($post_ID, 'bbpress_discussion_tags_copied', time());
}
/** Export comments from the post to the new bbPress topic */
if (!empty($bbppt_options['copy_comments'])) {
bbppt_import_comments($post_ID, $topic_ID);
update_post_meta($post_ID, 'bbpress_discussion_comments_copied', time());
}
if ($use_defaults) {
update_post_meta($post_ID, 'bbpress_discussion_use_defaults', true);
} else {
delete_post_meta($post_ID, 'bbpress_discussion_use_defaults');
update_post_meta($post_ID, 'bbpress_discussion_display_format', $topic_display);
update_post_meta($post_ID, 'bbpress_discussion_display_extras', $topic_display_extras);
}
}
do_action('bbppt_topic_assigned', $post_ID, $topic_ID);
} else {
if ($topic_forum != 0) {
/** if user has opted to create a new topic */
$topic_ID = $this->build_new_topic($post, $topic_forum);
if (!$topic_ID) {
// return an error of some kind
wp_die(__('There was an error creating a new topic.', 'bbpress-post-topics'), __('Error Creating bbPress Topic', 'bbpress-post-topics'));
} else {
update_post_meta($post_ID, 'use_bbpress_discussion_topic', true);
update_post_meta($post_ID, 'bbpress_discussion_topic_id', $topic_ID);
/** Update topic with tags from the post */
if ($bbppt_options['copy_tags']) {
$post_tags = wp_get_post_tags($post_ID);
$post_tags = array_map(create_function('$term', 'return $term->name;'), $post_tags);
wp_set_post_terms($topic_ID, join(',', $post_tags), bbp_get_topic_tag_tax_id(), false);
update_post_meta($post_ID, 'bbpress_discussion_tags_copied', time());
}
/** Export comments from the post to the new bbPress topic */
if ($bbppt_options['copy_comments']) {
bbppt_import_comments($post_ID, $topic_ID);
update_post_meta($post_ID, 'bbpress_discussion_comments_copied', time());
}
if ($use_defaults) {
update_post_meta($post_ID, 'bbpress_discussion_use_defaults', true);
} else {
update_post_meta($post_ID, 'bbpress_discussion_display_format', $topic_display);
update_post_meta($post_ID, 'bbpress_discussion_display_extras', $topic_display_extras);
}
}
do_action('bbppt_topic_created', $post_ID, $topic_ID);
}
}
} else {
delete_post_meta($post_ID, 'use_bbpress_discussion_topic');
delete_post_meta($post_ID, 'bbpress_discussion_topic_id');
delete_post_meta($post_ID, 'bbpress_discussion_use_defaults');
delete_post_meta($post_ID, 'bbpress_discussion_display_format');
delete_post_meta($post_ID, 'bbpress_discussion_display_extras');
delete_post_meta($post_ID, 'bbpress_discussion_tags_copied');
delete_post_meta($post_ID, 'bbpress_discussion_comments_copied');
}
$this->delete_draft_settings($post);
do_action('bbppt_topic_associated', $post_ID, $topic_ID);
}
示例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: tehnik_bbp_has_topics
function tehnik_bbp_has_topics($args = '')
{
global $wp_rewrite;
/** Defaults ************************************************************* */
// Other defaults
$default_topic_search = !empty($_REQUEST['ts']) ? $_REQUEST['ts'] : false;
$default_show_stickies = (bool) (bbp_is_single_forum() || bbp_is_topic_archive()) && false === $default_topic_search;
$default_post_parent = bbp_is_single_forum() ? bbp_get_forum_id() : 'any';
// Default argument array
$default = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $default_post_parent, 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC', 'posts_per_page' => bbp_get_topics_per_page(), 'paged' => bbp_get_paged(), 's' => $default_topic_search, 'show_stickies' => $default_show_stickies, 'max_num_pages' => false);
//Get an array of IDs which the current user has permissions to view
$allowed_forums = tehnik_bpp_get_permitted_post_ids(new WP_Query($default));
// The default forum query with allowed forum ids array added
$default['post__in'] = $allowed_forums;
// What are the default allowed statuses (based on user caps)
if (bbp_get_view_all()) {
// Default view=all statuses
$post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id());
// Add support for private status
if (current_user_can('read_private_topics')) {
$post_statuses[] = bbp_get_private_status_id();
}
// Join post statuses together
$default['post_status'] = join(',', $post_statuses);
// Lean on the 'perm' query var value of 'readable' to provide statuses
} else {
$default['perm'] = 'readable';
}
// Maybe query for topic tags
if (bbp_is_topic_tag()) {
$default['term'] = bbp_get_topic_tag_slug();
$default['taxonomy'] = bbp_get_topic_tag_tax_id();
}
/** Setup **************************************************************** */
// Parse arguments against default values
$r = bbp_parse_args($args, $default, 'has_topics');
// Get bbPress
$bbp = bbpress();
// Call the query
$bbp->topic_query = new WP_Query($r);
// Set post_parent back to 0 if originally set to 'any'
if ('any' == $r['post_parent']) {
$r['post_parent'] = 0;
}
// Limited the number of pages shown
if (!empty($r['max_num_pages'])) {
$bbp->topic_query->max_num_pages = $r['max_num_pages'];
}
/** Stickies ************************************************************* */
// Put sticky posts at the top of the posts array
if (!empty($r['show_stickies']) && $r['paged'] <= 1) {
// Get super stickies and stickies in this forum
$stickies = bbp_get_super_stickies();
// Get stickies for current forum
if (!empty($r['post_parent'])) {
$stickies = array_merge($stickies, bbp_get_stickies($r['post_parent']));
}
// Remove any duplicate stickies
$stickies = array_unique($stickies);
// We have stickies
if (is_array($stickies) && !empty($stickies)) {
// Start the offset at -1 so first sticky is at correct 0 offset
$sticky_offset = -1;
// Loop over topics and relocate stickies to the front.
foreach ($stickies as $sticky_index => $sticky_ID) {
// Get the post offset from the posts array
$post_offsets = wp_filter_object_list($bbp->topic_query->posts, array('ID' => $sticky_ID), 'OR', 'ID');
// Continue if no post offsets
if (empty($post_offsets)) {
continue;
}
// Loop over posts in current query and splice them into position
foreach (array_keys($post_offsets) as $post_offset) {
$sticky_offset++;
$sticky = $bbp->topic_query->posts[$post_offset];
// Remove sticky from current position
array_splice($bbp->topic_query->posts, $post_offset, 1);
// Move to front, after other stickies
array_splice($bbp->topic_query->posts, $sticky_offset, 0, array($sticky));
// Cleanup
unset($stickies[$sticky_index]);
unset($sticky);
}
// Cleanup
unset($post_offsets);
}
// Cleanup
unset($sticky_offset);
// If any posts have been excluded specifically, Ignore those that are sticky.
if (!empty($stickies) && !empty($r['post__not_in'])) {
$stickies = array_diff($stickies, $r['post__not_in']);
}
// Fetch sticky posts that weren't in the query results
if (!empty($stickies)) {
// Query to use in get_posts to get sticky posts
$sticky_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => 'any', 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC', 'include' => $stickies);
//Get an array of IDs which the current user has permissions to view
$allowed_forums = tehnik_bpp_get_permitted_post_ids(new WP_Query($sticky_query));
// The default forum query with allowed forum ids array added
$sticky_query['post__in'] = $allowed_forums;
//.........这里部分代码省略.........
示例8: bbp_get_topic_tag_names
/**
* Get topic tags for a specific topic ID
*
* @since bbPress (r4165)
*
* @param int $topic_id
* @param string $sep
* @return string
*/
function bbp_get_topic_tag_names($topic_id = 0, $sep = ', ')
{
$topic_id = bbp_get_topic_id($topic_id);
$topic_tags = array_filter((array) get_the_terms($topic_id, bbp_get_topic_tag_tax_id()));
$terms = array();
foreach ($topic_tags as $term) {
$terms[] = $term->name;
}
$terms = !empty($terms) ? implode($sep, $terms) : '';
return apply_filters('bbp_get_topic_tags', $terms, $topic_id);
}
示例9: filter_post_terms
/**
* Handle any terms submitted with a post flagged as spam
*
* @since bbPress (r3308)
*
* @param string $terms Comma-separated list of terms
* @param int $topic_id
* @param int $reply_id
*
* @uses bbp_get_reply_id() To get the reply_id
* @uses bbp_get_topic_id() To get the topic_id
* @uses wp_get_object_terms() To a post's current terms
* @uses update_post_meta() To add spam terms to post meta
*
* @return array Array of existing topic terms
*/
public function filter_post_terms($terms = '', $topic_id = 0, $reply_id = 0)
{
// Validate the reply_id and topic_id
$reply_id = bbp_get_reply_id($reply_id);
$topic_id = bbp_get_topic_id($topic_id);
// Get any pre-existing terms
$existing_terms = wp_get_object_terms($topic_id, bbp_get_topic_tag_tax_id(), array('fields' => 'names'));
// Save the terms for later in case the reply gets hammed
if (!empty($terms)) {
update_post_meta($reply_id, '_bbp_akismet_spam_terms', $terms);
}
// Keep the topic tags the same for now
return $existing_terms;
}
示例10: get_the_content
<div class="entry-content">
<?php
get_the_content() ? the_content() : wpautop(esc_html__('This is a collection of tags that are currently popular on our forums.', 'bbpress'));
?>
<div id="bbpress-forums">
<?php
bbp_breadcrumb();
?>
<div id="bbp-topic-hot-tags">
<?php
wp_tag_cloud(array('smallest' => 9, 'largest' => 38, 'number' => 80, 'taxonomy' => bbp_get_topic_tag_tax_id()));
?>
</div>
</div>
</div>
</div><!-- #bbp-topic-tags -->
<?php
}
?>
<?php
do_action('bbp_after_main_content');
?>
示例11: bbp_get_topic_tags
/**
* Get topic tags for a specific topic ID
*
* @since 2.6.0 bbPress (r5836)
*
* @param int $topic_id
*
* @return string
*/
function bbp_get_topic_tags($topic_id = 0)
{
$topic_id = bbp_get_topic_id($topic_id);
$terms = (array) get_the_terms($topic_id, bbp_get_topic_tag_tax_id());
$topic_tags = array_filter($terms);
return apply_filters('bbp_get_topic_tags', $topic_tags, $topic_id);
}
示例12: display_topics_of_tag_query
/**
* Filter the query for topic tags
*
* @since bbPress (r3637)
*
* @param array $args
* @return array
*/
public function display_topics_of_tag_query($args = array())
{
$args['tax_query'] = array(array('taxonomy' => bbp_get_topic_tag_tax_id(), 'field' => 'id', 'terms' => bbpress()->current_topic_tag_id));
return $args;
}
示例13: generate_rewrite_rules
/**
* Register bbPress-specific rewrite rules for uri's that are not
* setup for us by way of custom post types or taxonomies. This includes:
* - Front-end editing
* - Topic views
* - User profiles
*
* @since bbPress (r2688)
* @param WP_Rewrite $wp_rewrite bbPress-sepecific rules are appended in
* $wp_rewrite->rules
*/
public static function generate_rewrite_rules($wp_rewrite)
{
// Slugs
$view_slug = bbp_get_view_slug();
$user_slug = bbp_get_user_slug();
// Unique rewrite ID's
$edit_id = bbp_get_edit_rewrite_id();
$view_id = bbp_get_view_rewrite_id();
$user_id = bbp_get_user_rewrite_id();
$favs_id = bbp_get_user_favorites_rewrite_id();
$subs_id = bbp_get_user_subscriptions_rewrite_id();
$tops_id = bbp_get_user_topics_rewrite_id();
$reps_id = bbp_get_user_replies_rewrite_id();
// Rewrite rule matches used repeatedly below
$root_rule = '/([^/]+)/?$';
$edit_rule = '/([^/]+)/edit/?$';
$feed_rule = '/([^/]+)/feed/?$';
$page_rule = '/([^/]+)/page/?([0-9]{1,})/?$';
// User profile rules
$tops_rule = '/([^/]+)/topics/?$';
$reps_rule = '/([^/]+)/replies/?$';
$favs_rule = '/([^/]+)/' . bbp_get_user_favorites_slug() . '/?$';
$subs_rule = '/([^/]+)/' . bbp_get_user_subscriptions_slug() . '/?$';
$tops_page_rule = '/([^/]+)/topics/page/?([0-9]{1,})/?$';
$reps_page_rule = '/([^/]+)/replies/page/?([0-9]{1,})/?$';
$favs_page_rule = '/([^/]+)/' . bbp_get_user_favorites_slug() . '/page/?([0-9]{1,})/?$';
$subs_page_rule = '/([^/]+)/' . bbp_get_user_subscriptions_slug() . '/page/?([0-9]{1,})/?$';
// New bbPress specific rules to merge with existing that are not
// handled automatically by custom post types or taxonomy types
$bbp_rules = array(bbp_get_forum_slug() . $edit_rule => 'index.php?' . bbp_get_forum_post_type() . '=' . $wp_rewrite->preg_index(1) . '&' . $edit_id . '=1', bbp_get_topic_slug() . $edit_rule => 'index.php?' . bbp_get_topic_post_type() . '=' . $wp_rewrite->preg_index(1) . '&' . $edit_id . '=1', bbp_get_reply_slug() . $edit_rule => 'index.php?' . bbp_get_reply_post_type() . '=' . $wp_rewrite->preg_index(1) . '&' . $edit_id . '=1', bbp_get_topic_tag_tax_slug() . $edit_rule => 'index.php?' . bbp_get_topic_tag_tax_id() . '=' . $wp_rewrite->preg_index(1) . '&' . $edit_id . '=1', $user_slug . $tops_page_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $tops_id . '=1&paged=' . $wp_rewrite->preg_index(2), $user_slug . $reps_page_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $reps_id . '=1&paged=' . $wp_rewrite->preg_index(2), $user_slug . $favs_page_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $favs_id . '=1&paged=' . $wp_rewrite->preg_index(2), $user_slug . $subs_page_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $subs_id . '=1&paged=' . $wp_rewrite->preg_index(2), $user_slug . $tops_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $tops_id . '=1', $user_slug . $reps_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $reps_id . '=1', $user_slug . $favs_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $favs_id . '=1', $user_slug . $subs_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $subs_id . '=1', $user_slug . $edit_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $edit_id . '=1', $user_slug . $root_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1), $view_slug . $page_rule => 'index.php?' . $view_id . '=' . $wp_rewrite->preg_index(1) . '&paged=' . $wp_rewrite->preg_index(2), $view_slug . $feed_rule => 'index.php?' . $view_id . '=' . $wp_rewrite->preg_index(1) . '&feed=' . $wp_rewrite->preg_index(2), $view_slug . $root_rule => 'index.php?' . $view_id . '=' . $wp_rewrite->preg_index(1));
// Merge bbPress rules with existing
$wp_rewrite->rules = array_merge($bbp_rules, $wp_rewrite->rules);
// Return merged rules
return $wp_rewrite;
}
示例14: bbp_current_user_can_see
/**
* Can the current user see a specific UI element?
*
* Used when registering post-types and taxonomies to decide if 'show_ui' should
* be set to true or false. Also used for fine-grained control over which admin
* sections are visible under what conditions.
*
* This function is in bbp-core-caps.php rather than in /bbp-admin so that it
* can be used during the bbp_register_post_types action.
*
* @since bbPress (r3944)
*
* @uses current_user_can() To check the 'moderate' capability
* @uses bbp_get_forum_post_type()
* @uses bbp_get_topic_post_type()
* @uses bbp_get_reply_post_type()
* @uses bbp_get_topic_tag_tax_id()
* @uses is_plugin_active()
* @uses is_super_admin()
* @return bool Results of current_user_can( 'moderate' ) check.
*/
function bbp_current_user_can_see($component = '')
{
// Define local variable
$retval = false;
// Which component are we checking UI visibility for?
switch ($component) {
/** Everywhere ********************************************************/
case bbp_get_forum_post_type():
// Forums
// Forums
case bbp_get_topic_post_type():
// Topics
// Topics
case bbp_get_reply_post_type():
// Replies
// Replies
case bbp_get_topic_tag_tax_id():
// Topic-Tags
$retval = current_user_can('moderate');
break;
/** Admin Exclusive ***************************************************/
/** Admin Exclusive ***************************************************/
case 'bbp_settings_buddypress':
// BuddyPress Extension
$retval = is_plugin_active('buddypress/bp-loader.php') && defined('BP_VERSION') && is_super_admin();
break;
case 'bbp_settings_akismet':
// Akismet Extension
$retval = is_plugin_active('akismet/akismet.php') && defined('AKISMET_VERSION') && is_super_admin();
break;
case 'bbp_tools_page':
// Tools Page
// Tools Page
case 'bbp_tools_repair_page':
// Tools - Repair Page
// Tools - Repair Page
case 'bbp_tools_import_page':
// Tools - Import Page
// Tools - Import Page
case 'bbp_tools_reset_page':
// Tools - Reset Page
// Tools - Reset Page
case 'bbp_settings?page':
// Settings Page
// Settings Page
case 'bbp_settings_main':
// Settings - General
// Settings - General
case 'bbp_settings_theme_compat':
// Settings - Theme compat
// Settings - Theme compat
case 'bbp_settings_root_slugs':
// Settings - Root slugs
// Settings - Root slugs
case 'bbp_settings_single_slugs':
// Settings - Single slugs
// Settings - Single slugs
case 'bbp_settings_per_page':
// Settings - Single slugs
// Settings - Single slugs
case 'bbp_settings_per_page_rss':
// Settings - Single slugs
// Settings - Single slugs
default:
// Anything else
$retval = current_user_can(bbpress()->admin->minimum_capability);
break;
}
return (bool) apply_filters('bbp_current_user_can_see', (bool) $retval, $component);
}
示例15: add_rewrite_rules
/**
* Add bbPress-specific rewrite rules for uri's that are not
* setup for us by way of custom post types or taxonomies. This includes:
* - Front-end editing
* - Topic views
* - User profiles
*
* @since bbPress (r2688)
* @todo Extract into an API
*/
public static function add_rewrite_rules()
{
/** Setup *************************************************************/
// Add rules to top or bottom?
$priority = 'top';
// Single Slugs
$forum_slug = bbp_get_forum_slug();
$topic_slug = bbp_get_topic_slug();
$reply_slug = bbp_get_reply_slug();
$ttag_slug = bbp_get_topic_tag_tax_slug();
// Archive Slugs
$user_slug = bbp_get_user_slug();
$view_slug = bbp_get_view_slug();
$search_slug = bbp_get_search_slug();
$topic_archive_slug = bbp_get_topic_archive_slug();
$reply_archive_slug = bbp_get_reply_archive_slug();
// Tertiary Slugs
$feed_slug = 'feed';
$edit_slug = 'edit';
$paged_slug = bbp_get_paged_slug();
$user_favs_slug = bbp_get_user_favorites_slug();
$user_subs_slug = bbp_get_user_subscriptions_slug();
// Unique rewrite ID's
$feed_id = 'feed';
$edit_id = bbp_get_edit_rewrite_id();
$view_id = bbp_get_view_rewrite_id();
$paged_id = bbp_get_paged_rewrite_id();
$search_id = bbp_get_search_rewrite_id();
$user_id = bbp_get_user_rewrite_id();
$user_favs_id = bbp_get_user_favorites_rewrite_id();
$user_subs_id = bbp_get_user_subscriptions_rewrite_id();
$user_tops_id = bbp_get_user_topics_rewrite_id();
$user_reps_id = bbp_get_user_replies_rewrite_id();
// Rewrite rule matches used repeatedly below
$root_rule = '/([^/]+)/?$';
$feed_rule = '/([^/]+)/' . $feed_slug . '/?$';
$edit_rule = '/([^/]+)/' . $edit_slug . '/?$';
$paged_rule = '/([^/]+)/' . $paged_slug . '/?([0-9]{1,})/?$';
// Search rules (without slug check)
$search_root_rule = '/?$';
$search_paged_rule = '/' . $paged_slug . '/?([0-9]{1,})/?$';
/** Add ***************************************************************/
// User profile rules
$tops_rule = '/([^/]+)/' . $topic_archive_slug . '/?$';
$reps_rule = '/([^/]+)/' . $reply_archive_slug . '/?$';
$favs_rule = '/([^/]+)/' . $user_favs_slug . '/?$';
$subs_rule = '/([^/]+)/' . $user_subs_slug . '/?$';
$tops_paged_rule = '/([^/]+)/' . $topic_archive_slug . '/' . $paged_slug . '/?([0-9]{1,})/?$';
$reps_paged_rule = '/([^/]+)/' . $reply_archive_slug . '/' . $paged_slug . '/?([0-9]{1,})/?$';
$favs_paged_rule = '/([^/]+)/' . $user_favs_slug . '/' . $paged_slug . '/?([0-9]{1,})/?$';
$subs_paged_rule = '/([^/]+)/' . $user_subs_slug . '/' . $paged_slug . '/?([0-9]{1,})/?$';
// Edit Forum|Topic|Reply|Topic-tag
add_rewrite_rule($forum_slug . $edit_rule, 'index.php?' . bbp_get_forum_post_type() . '=$matches[1]&' . $edit_id . '=1', $priority);
add_rewrite_rule($topic_slug . $edit_rule, 'index.php?' . bbp_get_topic_post_type() . '=$matches[1]&' . $edit_id . '=1', $priority);
add_rewrite_rule($reply_slug . $edit_rule, 'index.php?' . bbp_get_reply_post_type() . '=$matches[1]&' . $edit_id . '=1', $priority);
add_rewrite_rule($ttag_slug . $edit_rule, 'index.php?' . bbp_get_topic_tag_tax_id() . '=$matches[1]&' . $edit_id . '=1', $priority);
// User Pagination|Edit|View
add_rewrite_rule($user_slug . $tops_paged_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_tops_id . '=1&' . $paged_id . '=$matches[2]', $priority);
add_rewrite_rule($user_slug . $reps_paged_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_reps_id . '=1&' . $paged_id . '=$matches[2]', $priority);
add_rewrite_rule($user_slug . $favs_paged_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_favs_id . '=1&' . $paged_id . '=$matches[2]', $priority);
add_rewrite_rule($user_slug . $subs_paged_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_subs_id . '=1&' . $paged_id . '=$matches[2]', $priority);
add_rewrite_rule($user_slug . $tops_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_tops_id . '=1', $priority);
add_rewrite_rule($user_slug . $reps_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_reps_id . '=1', $priority);
add_rewrite_rule($user_slug . $favs_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_favs_id . '=1', $priority);
add_rewrite_rule($user_slug . $subs_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_subs_id . '=1', $priority);
add_rewrite_rule($user_slug . $edit_rule, 'index.php?' . $user_id . '=$matches[1]&' . $edit_id . '=1', $priority);
add_rewrite_rule($user_slug . $root_rule, 'index.php?' . $user_id . '=$matches[1]', $priority);
// Topic-View Pagination|Feed|View
add_rewrite_rule($view_slug . $paged_rule, 'index.php?' . $view_id . '=$matches[1]&' . $paged_id . '=$matches[2]', $priority);
add_rewrite_rule($view_slug . $feed_rule, 'index.php?' . $view_id . '=$matches[1]&' . $feed_id . '=$matches[2]', $priority);
add_rewrite_rule($view_slug . $root_rule, 'index.php?' . $view_id . '=$matches[1]', $priority);
// Search All
add_rewrite_rule($search_slug . $search_paged_rule, 'index.php?' . $paged_id . '=$matches[1]', $priority);
add_rewrite_rule($search_slug . $search_root_rule, 'index.php?' . $search_id, $priority);
}