本文整理汇总了PHP中bp_is_user_active函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_is_user_active函数的具体用法?PHP bp_is_user_active怎么用?PHP bp_is_user_active使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_is_user_active函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_activity_maybe_load_mentions_scripts
/**
* Should BuddyPress load the mentions scripts and related assets, including results to prime the
* mentions suggestions?
*
* @since 2.1.0
*
* @return bool True if mentions scripts should be loaded.
*/
function bp_activity_maybe_load_mentions_scripts()
{
$mentions_enabled = bp_activity_do_mentions() && bp_is_user_active();
$load_mentions = $mentions_enabled && (bp_is_activity_component() || is_admin());
/**
* Filters whether or not BuddyPress should load mentions scripts and assets.
*
* @since 2.1.0
*
* @param bool $load_mentions True to load mentions assets, false otherwise.
* @param bool $mentions_enabled True if mentions are enabled.
*/
return (bool) apply_filters('bp_activity_maybe_load_mentions_scripts', $load_mentions, $mentions_enabled);
}
示例2: bp_get_group_class
/**
* Return the row class of a group
*
* @global BP_Groups_Template $groups_template
* @return string Row class of the group
* @since BuddyPress (1.7)
*/
function bp_get_group_class()
{
global $groups_template;
$classes = array();
$pos_in_loop = (int) $groups_template->current_group;
// If we've only one group in the loop, don't both with odd and even.
if ($groups_template->group_count > 1) {
$classes[] = $pos_in_loop % 2 ? 'even' : 'odd';
} else {
$classes[] = 'bp-single-group';
}
// Group type - public, private, hidden.
$classes[] = esc_attr($groups_template->group->status);
// User's group status
if (bp_is_user_active()) {
if (bp_group_is_admin()) {
$classes[] = 'is-admin';
}
if (bp_group_is_member()) {
$classes[] = 'is-member';
}
if (bp_group_is_mod()) {
$classes[] = 'is-mod';
}
}
$classes = apply_filters('bp_get_group_class', $classes);
$classes = array_merge($classes, array());
$retval = 'class="' . join(' ', $classes) . '"';
return $retval;
}
示例3: bp_get_group_class
/**
* Get the row class of the current group in the loop.
*
* @since 1.7.0
*
* @param array $classes Array of custom classes.
* @return string Row class of the group.
*/
function bp_get_group_class($classes = array())
{
global $groups_template;
// Add even/odd classes, but only if there's more than 1 group.
if ($groups_template->group_count > 1) {
$pos_in_loop = (int) $groups_template->current_group;
$classes[] = $pos_in_loop % 2 ? 'even' : 'odd';
// If we've only one group in the loop, don't bother with odd and even.
} else {
$classes[] = 'bp-single-group';
}
// Group type - public, private, hidden.
$classes[] = sanitize_key($groups_template->group->status);
// User's group role.
if (bp_is_user_active()) {
// Admin.
if (bp_group_is_admin()) {
$classes[] = 'is-admin';
}
// Moderator.
if (bp_group_is_mod()) {
$classes[] = 'is-mod';
}
// Member.
if (bp_group_is_member()) {
$classes[] = 'is-member';
}
}
// Whether a group avatar will appear.
if (bp_disable_group_avatar_uploads() || !buddypress()->avatar->show_avatars) {
$classes[] = 'group-no-avatar';
} else {
$classes[] = 'group-has-avatar';
}
/**
* Filters classes that will be applied to row class of the current group in the loop.
*
* @since 1.7.0
*
* @param array $classes Array of determined classes for the row.
*/
$classes = apply_filters('bp_get_group_class', $classes);
$classes = array_merge($classes, array());
$retval = 'class="' . join(' ', $classes) . '"';
return $retval;
}
示例4: bp_is_user_inactive
/**
* Check whether user is not active.
*
* @since 1.6.0
*
* @todo No need for the user fallback checks, since they're done in
* bp_is_user_active().
*
* @param int $user_id The user ID to check.
* @return bool True if inactive, otherwise false.
*/
function bp_is_user_inactive($user_id = 0)
{
// Default to current user.
if (empty($user_id) && is_user_logged_in()) {
$user_id = bp_loggedin_user_id();
}
// No user to check.
if (empty($user_id)) {
return false;
}
// Return the inverse of active.
return !bp_is_user_active($user_id);
}
示例5: bp_activity_maybe_load_mentions_scripts
/**
* Should BuddyPress load the mentions scripts and related assets, including results to prime the
* mentions suggestions?
*
* @return bool True if mentions scripts should be loaded.
* @since BuddyPress (2.1.0)
*/
function bp_activity_maybe_load_mentions_scripts()
{
$retval = bp_activity_do_mentions() && bp_is_user_active() && (bp_is_activity_component() || bp_is_blog_page() && is_singular() && comments_open() || is_admin());
return (bool) apply_filters('bp_activity_maybe_load_mentions_scripts', $retval);
}
示例6: validate
/**
* Validate and sanitise the parameters for the suggestion service query.
*
* Be sure to call this class' version of this method when implementing it in your own service.
* If validation fails, you must return a WP_Error object.
*
* @since 2.1.0
*
* @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool).
*/
public function validate()
{
$this->args['limit'] = absint($this->args['limit']);
$this->args['term'] = trim(sanitize_text_field($this->args['term']));
/**
* Filters the arguments to be validated for the BP_Suggestions query.
*
* @since 2.1.0
*
* @param BP_Suggestions $value Arguments to be validated.
* @param BP_Suggestions $this Current BP_Suggestions instance.
*/
$this->args = apply_filters('bp_suggestions_args', $this->args, $this);
// Check for invalid or missing mandatory parameters.
if (!$this->args['limit'] || !$this->args['term']) {
return new WP_Error('missing_parameter');
}
// Check for blocked users (e.g. deleted accounts, or spammers).
if (is_user_logged_in() && !bp_is_user_active(get_current_user_id())) {
return new WP_Error('invalid_user');
}
/**
* Filters the status of validation for the BP_Suggestions query.
*
* @since 2.1.0
*
* @param bool $value Whether or not the values are valid.
* @param BP_Suggestions $this Current BP_Suggestions instance.
*/
return apply_filters('bp_suggestions_validate_args', true, $this);
}
示例7: validate
/**
* Validate and sanitise the parameters for the suggestion service query.
*
* Be sure to call this class' version of this method when implementing it in your own service.
* If validation fails, you must return a WP_Error object.
*
* @return true|WP_Error If validation fails, return a WP_Error object. On success, return true (bool).
* @since BuddyPress (2.1.0)
*/
public function validate() {
$this->args['limit'] = absint( $this->args['limit'] );
$this->args['term'] = trim( sanitize_text_field( $this->args['term'] ) );
$this->args = apply_filters( 'bp_suggestions_args', $this->args, $this );
// Check for invalid or missing mandatory parameters.
if ( ! $this->args['limit'] || ! $this->args['term'] ) {
return new WP_Error( 'missing_parameter' );
}
// Check for blocked users (e.g. deleted accounts, or spammers).
if ( is_user_logged_in() && ! bp_is_user_active( get_current_user_id() ) ) {
return new WP_Error( 'invalid_user' );
}
return apply_filters( 'bp_suggestions_validate_args', true, $this );
}
示例8: bp_ajax_get_suggestions
/**
* AJAX endpoint for Suggestions API lookups.
*
* @since 2.1.0
*/
function bp_ajax_get_suggestions()
{
if (!bp_is_user_active() || empty($_GET['term']) || empty($_GET['type'])) {
wp_send_json_error('missing_parameter');
exit;
}
$args = array('term' => sanitize_text_field($_GET['term']), 'type' => sanitize_text_field($_GET['type']));
// Support per-Group suggestions.
if (!empty($_GET['group-id'])) {
$args['group_id'] = absint($_GET['group-id']);
}
$results = bp_core_get_suggestions($args);
if (is_wp_error($results)) {
wp_send_json_error($results->get_error_message());
exit;
}
wp_send_json_success($results);
}
示例9: bp_ajax_get_suggestions
/**
* AJAX endpoint for Suggestions API lookups.
*
* @since BuddyPress (2.1.0)
*/
function bp_ajax_get_suggestions()
{
if (!bp_is_user_active() || empty($_GET['term']) || empty($_GET['type'])) {
wp_send_json_error('missing_parameter');
exit;
}
$results = bp_core_get_suggestions(array('term' => sanitize_text_field($_GET['term']), 'type' => sanitize_text_field($_GET['type'])));
if (is_wp_error($results)) {
wp_send_json_error($results->get_error_message());
exit;
}
wp_send_json_success($results);
}