本文整理汇总了PHP中bbp_is_topic_anonymous函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_is_topic_anonymous函数的具体用法?PHP bbp_is_topic_anonymous怎么用?PHP bbp_is_topic_anonymous使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_is_topic_anonymous函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: td_bbp_change_avatar_size
function td_bbp_change_avatar_size($author_avatar, $topic_id, $size)
{
$author_avatar = '';
if ($size == 14) {
$size = 40;
}
$topic_id = bbp_get_topic_id($topic_id);
if (!empty($topic_id)) {
if (!bbp_is_topic_anonymous($topic_id)) {
$author_avatar = get_avatar(bbp_get_topic_author_id($topic_id), $size);
} else {
$author_avatar = get_avatar(get_post_meta($topic_id, '_bbp_anonymous_email', true), $size);
}
}
return $author_avatar;
}
示例2: bbp_form_topic_status_dropdown
<?php
bbp_form_topic_status_dropdown();
?>
</p>
<?php
do_action('bbp_theme_after_topic_form_status');
?>
<?php
}
?>
<?php
if (bbp_is_subscriptions_active() && !bbp_is_anonymous() && (!bbp_is_topic_edit() || bbp_is_topic_edit() && !bbp_is_topic_anonymous())) {
?>
<?php
do_action('bbp_theme_before_topic_form_subscriptions');
?>
<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();
?>
" />
示例3: bbp_get_topic_author_email
/**
* Return the topic author email address
*
* @since 2.0.0 bbPress (r3445)
*
* @param int $topic_id Optional. Reply id
* @uses bbp_get_topic_id() To get the topic id
* @uses bbp_is_topic_anonymous() To check if the topic is by an anonymous
* user
* @uses bbp_get_topic_author_id() To get the topic author id
* @uses get_userdata() To get the user data
* @uses get_post_meta() To get the anonymous poster's email
* @uses apply_filters() Calls bbp_get_topic_author_email with the author
* email & topic id
* @return string Topic author email address
*/
function bbp_get_topic_author_email($topic_id = 0)
{
$topic_id = bbp_get_topic_id($topic_id);
// Not anonymous user
if (!bbp_is_topic_anonymous($topic_id)) {
// Use topic author email address
$user_id = bbp_get_topic_author_id($topic_id);
$user = get_userdata($user_id);
$author_email = !empty($user->user_email) ? $user->user_email : '';
// Anonymous
} else {
// Get email from post meta
$author_email = get_post_meta($topic_id, '_bbp_anonymous_email', true);
// Sanity check for missing email address
if (empty($author_email)) {
$author_email = '';
}
}
return apply_filters('bbp_get_topic_author_email', $author_email, $topic_id);
}
示例4: 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)) {
//.........这里部分代码省略.........
示例5: topic_update
/**
* Update the activity stream entry when a topic status changes
*
* @param int $post_id
* @param obj $post
* @uses get_post_type()
* @uses bbp_get_topic_post_type()
* @uses bbp_get_topic_id()
* @uses bbp_is_topic_anonymous()
* @uses bbp_get_public_status_id()
* @uses bbp_get_closed_status_id()
* @uses bbp_get_topic_forum_id()
* @uses bbp_get_topic_author_id()
* @return Bail early if not a topic, or topic is by anonymous user
*/
public function topic_update($topic_id, $post)
{
// Bail early if not a topic
if (get_post_type($post) != bbp_get_topic_post_type()) {
return;
}
$topic_id = bbp_get_topic_id($topic_id);
// Bail early if topic is by anonymous user
if (bbp_is_topic_anonymous($topic_id)) {
return;
}
$anonymous_data = array();
// Action based on new status
if (in_array($post->post_status, array(bbp_get_public_status_id(), bbp_get_closed_status_id()))) {
// Validate topic data
$forum_id = bbp_get_topic_forum_id($topic_id);
$topic_author_id = bbp_get_topic_author_id($topic_id);
$this->topic_create($topic_id, $forum_id, $anonymous_data, $topic_author_id);
} else {
$this->topic_delete($topic_id);
}
}
示例6: bbp_fix_post_author
/**
* Fix post author id on post save
*
* When a logged in user changes the status of an anonymous reply or topic, or
* edits it, the post_author field is set to the logged in user's id. This
* function fixes that.
*
* @since 2.0.0 bbPress (r2734)
*
* @param array $data Post data
* @param array $postarr Original post array (includes post id)
* @uses bbp_get_topic_post_type() To get the topic post type
* @uses bbp_get_reply_post_type() To get the reply post type
* @uses bbp_is_topic_anonymous() To check if the topic is by an anonymous user
* @uses bbp_is_reply_anonymous() To check if the reply is by an anonymous user
* @return array Data
*/
function bbp_fix_post_author($data = array(), $postarr = array())
{
// Post is not being updated or the post_author is already 0, return
if (empty($postarr['ID']) || empty($data['post_author'])) {
return $data;
}
// Post is not a topic or reply, return
if (!in_array($data['post_type'], array(bbp_get_topic_post_type(), bbp_get_reply_post_type()))) {
return $data;
}
// Is the post by an anonymous user?
if (bbp_get_topic_post_type() === $data['post_type'] && !bbp_is_topic_anonymous($postarr['ID']) || bbp_get_reply_post_type() === $data['post_type'] && !bbp_is_reply_anonymous($postarr['ID'])) {
return $data;
}
// The post is being updated. It is a topic or a reply and is written by an anonymous user.
// Set the post_author back to 0
$data['post_author'] = 0;
return $data;
}
示例7: bbp_current_user_can_access_anonymous_user_form
/**
* Performs a series of checks to ensure the current user should see the
* anonymous user form fields.
*
* @since 2.5.0 bbPress (r5119)
*
* @uses bbp_is_anonymous()
* @uses bbp_is_topic_edit()
* @uses bbp_is_topic_anonymous()
* @uses bbp_is_reply_edit()
* @uses bbp_is_reply_anonymous()
*
* @return bool
*/
function bbp_current_user_can_access_anonymous_user_form()
{
// Users need to earn access
$retval = false;
// User is not logged in, and anonymous posting is allowed
if (bbp_is_anonymous()) {
$retval = true;
// User is editing a topic, and topic is authored by anonymous user
} elseif (bbp_is_topic_edit() && bbp_is_topic_anonymous()) {
$retval = true;
// User is editing a reply, and reply is authored by anonymous user
} elseif (bbp_is_reply_edit() && bbp_is_reply_anonymous()) {
$retval = true;
}
// Allow access to be filtered
return (bool) apply_filters('bbp_current_user_can_access_anonymous_user_form', (bool) $retval);
}
示例8:
<?php
/**
* Anonymous User
*
* @package bbPress
* @subpackage Theme
*/
?>
<?php
if (bbp_is_anonymous() || bbp_is_topic_edit() && bbp_is_topic_anonymous() || bbp_is_reply_edit() && bbp_is_reply_anonymous()) {
?>
<?php
do_action('bbp_theme_before_anonymous_form');
?>
<fieldset class="bbp-form">
<legend><?php
bbp_is_topic_edit() || bbp_is_reply_edit() ? _e('Author Information', 'bbpress') : _e('Your information:', 'bbpress');
?>
</legend>
<?php
do_action('bbp_theme_anonymous_form_extras_top');
?>
<p>
<label for="bbp_anonymous_author"><?php
_e('Name (required):', 'bbpress');
示例9: bbp_author_metabox
/**
* Anonymous user information metabox
*
* @since 2.0.0 bbPress (r2828)
*
* @uses bbp_is_reply_anonymous() To check if reply is anonymous
* @uses bbp_is_topic_anonymous() To check if topic is anonymous
* @uses get_the_ID() To get the global post ID
* @uses get_post_meta() To get the author user information
*/
function bbp_author_metabox()
{
// Post ID
$post_id = get_the_ID();
// Show extra bits if topic/reply is anonymous
if (bbp_is_reply_anonymous($post_id) || bbp_is_topic_anonymous($post_id)) {
?>
<p>
<strong class="label"><?php
esc_html_e('Name:', 'bbpress');
?>
</strong>
<label class="screen-reader-text" for="bbp_anonymous_name"><?php
esc_html_e('Name', 'bbpress');
?>
</label>
<input type="text" id="bbp_anonymous_name" name="bbp_anonymous_name" value="<?php
echo esc_attr(get_post_meta($post_id, '_bbp_anonymous_name', true));
?>
" />
</p>
<p>
<strong class="label"><?php
esc_html_e('Email:', 'bbpress');
?>
</strong>
<label class="screen-reader-text" for="bbp_anonymous_email"><?php
esc_html_e('Email', 'bbpress');
?>
</label>
<input type="text" id="bbp_anonymous_email" name="bbp_anonymous_email" value="<?php
echo esc_attr(get_post_meta($post_id, '_bbp_anonymous_email', true));
?>
" />
</p>
<p>
<strong class="label"><?php
esc_html_e('Website:', 'bbpress');
?>
</strong>
<label class="screen-reader-text" for="bbp_anonymous_website"><?php
esc_html_e('Website', 'bbpress');
?>
</label>
<input type="text" id="bbp_anonymous_website" name="bbp_anonymous_website" value="<?php
echo esc_attr(get_post_meta($post_id, '_bbp_anonymous_website', true));
?>
" />
</p>
<?php
} else {
?>
<p>
<strong class="label"><?php
esc_html_e('ID:', 'bbpress');
?>
</strong>
<label class="screen-reader-text" for="bbp_author_id"><?php
esc_html_e('ID', 'bbpress');
?>
</label>
<input type="text" id="bbp_author_id" name="post_author_override" value="<?php
echo esc_attr(bbp_get_global_post_field('post_author'));
?>
" data-ajax-url="<?php
echo esc_url(wp_nonce_url(add_query_arg(array('action' => 'bbp_suggest_user'), admin_url('admin-ajax.php', 'relative')), 'bbp_suggest_user_nonce'));
?>
" />
</p>
<?php
}
?>
<p>
<strong class="label"><?php
esc_html_e('IP:', 'bbpress');
?>
</strong>
<label class="screen-reader-text" for="bbp_author_ip_address"><?php
esc_html_e('IP Address', 'bbpress');
?>
</label>
<input type="text" id="bbp_author_ip_address" name="bbp_author_ip_address" value="<?php
echo esc_attr(get_post_meta($post_id, '_bbp_author_ip', true));
//.........这里部分代码省略.........
示例10: bbp_author_metabox
/**
* Anonymous user information metabox
*
* @since bbPress (r2828)
*
* @uses bbp_is_reply_anonymous() To check if reply is anonymous
* @uses bbp_is_topic_anonymous() To check if topic is anonymous
* @uses get_the_ID() To get the global post ID
* @uses get_post_meta() To get the author user information
*/
function bbp_author_metabox()
{
// Post ID
$post_id = get_the_ID();
// Show extra bits if topic/reply is anonymous
if (bbp_is_reply_anonymous($post_id) || bbp_is_topic_anonymous($post_id)) {
?>
<p><strong><?php
_e('Name', 'bbpress');
?>
</strong></p>
<p>
<label class="screen-reader-text" for="bbp_anonymous_name"><?php
_e('Name', 'bbpress');
?>
</label>
<input type="text" id="bbp_anonymous_name" name="bbp_anonymous_name" value="<?php
echo esc_attr(get_post_meta($post_id, '_bbp_anonymous_name', true));
?>
" size="25" />
</p>
<p><strong><?php
_e('Email', 'bbpress');
?>
</strong></p>
<p>
<label class="screen-reader-text" for="bbp_anonymous_email"><?php
_e('Email', 'bbpress');
?>
</label>
<input type="text" id="bbp_anonymous_email" name="bbp_anonymous_email" value="<?php
echo esc_attr(get_post_meta($post_id, '_bbp_anonymous_email', true));
?>
" size="25" />
</p>
<p><strong><?php
_e('Website', 'bbpress');
?>
</strong></p>
<p>
<label class="screen-reader-text" for="bbp_anonymous_website"><?php
_e('Website', 'bbpress');
?>
</label>
<input type="text" id="bbp_anonymous_website" name="bbp_anonymous_website" value="<?php
echo esc_attr(get_post_meta($post_id, '_bbp_anonymous_website', true));
?>
" size="25" />
</p>
<?php
}
?>
<p><strong><?php
_e('IP Address', 'bbpress');
?>
</strong></p>
<p>
<label class="screen-reader-text" for="bbp_author_ip_address"><?php
_e('IP Address', 'bbpress');
?>
</label>
<input type="text" id="bbp_author_ip_address" name="bbp_author_ip_address" value="<?php
echo esc_attr(get_post_meta($post_id, '_bbp_author_ip', true));
?>
" size="25" disabled="disabled" />
</p>
<?php
do_action('bbp_author_metabox', $post_id);
}
示例11: get_data
/**
* Get the data being exported
*
* @access public
* @since 1.0
* @return array $data Data for Export
*/
public function get_data()
{
$topics = get_posts(array('post_parent' => $this->forum_id, 'nopaging' => true, 'post_type' => bbp_get_topic_post_type()));
foreach ($topics as $topic) {
$topic_anonymous = bbp_is_topic_anonymous($topic->ID);
if ($topic_anonymous) {
$email = get_post_meta($topic->ID, '_bbp_anonymous_email', true);
} else {
$email = get_the_author_meta('email', $topic->post_author);
}
$data[] = array('post_type' => bbp_get_topic_post_type(), 'post_author' => $email, 'user_login' => get_the_author_meta('user_login', $topic->post_author), 'post_parent' => $topic->post_parent, 'post_content' => htmlentities($topic->post_content), 'post_title' => $topic->post_title, 'post_date_gmt' => $topic->post_date_gmt, 'post_date' => $topic->post_date, 'anonymous' => $topic_anonymous ? '1' : '0', 'voices' => bbp_get_topic_voice_count($topic->ID), 'reply_count' => bbp_get_topic_post_count($topic->ID), 'resolved' => function_exists('bbps_topic_resolved') && bbps_topic_resolved($topic->ID) ? '1' : 0);
$replies = get_posts(array('post_parent' => $topic->ID, 'nopaging' => true, 'post_type' => bbp_get_reply_post_type()));
if ($replies) {
foreach ($replies as $reply) {
$reply_anonymous = bbp_is_reply_anonymous($reply->ID);
if ($reply_anonymous) {
$reply_email = get_post_meta($topic->ID, '_bbp_anonymous_email', true);
} else {
$reply_email = get_the_author_meta('email', $reply->post_author);
}
$data[] = array('post_type' => bbp_get_reply_post_type(), 'post_author' => $reply_email, 'user_login' => get_the_author_meta('user_login', $reply->post_author), 'post_parent' => $reply->post_parent, 'post_content' => htmlentities($reply->post_content), 'post_title' => $reply->post_title, 'post_date_gmt' => $reply->post_date_gmt, 'post_date' => $reply->post_date, 'anonymous' => $reply_anonymous ? '1' : '0', 'voices' => '0', 'reply_count' => '0', 'resolved' => '0');
}
}
}
$data = apply_filters('bbp_export_get_data', $data);
return $data;
}