[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

/src/includes/common/ -> functions.php (summary)

bbPress Common Functions Common functions are ones that are used by more than one component, like forums, topics, replies, users, topic tags, etc...

File Size: 2511 lines (75 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 45 functions

  bbp_get_post_types()
  bbp_get_redirect_to()
  bbp_add_view_all()
  bbp_remove_view_all()
  bbp_get_view_all()
  bbp_get_paged()
  bbp_get_unique_array_values()
  bbp_fix_post_author()
  bbp_past_edit_lock()
  bbp_get_trash_days()
  bbp_get_statistics()
  bbp_filter_anonymous_post_data()
  bbp_sanitize_anonymous_post_author()
  bbp_update_anonymous_post_author()
  bbp_check_for_duplicate()
  bbp_check_for_flood()
  bbp_check_for_moderation()
  bbp_check_for_blacklist()
  bbp_get_do_not_reply_address()
  bbp_notify_topic_subscribers()
  bbp_notify_forum_subscribers()
  bbp_notify_subscribers()
  bbp_get_email_addresses_from_user_ids()
  bbp_logout_url()
  bbp_parse_args()
  bbp_query_post_parent__in()
  bbp_get_public_child_last_id()
  bbp_get_child_counts()
  bbp_filter_child_counts_list()
  bbp_get_public_child_count()
  bbp_get_non_public_child_count()
  bbp_get_public_child_ids()
  bbp_get_all_child_ids()
  bbp_update_post_family_caches()
  bbp_update_post_author_caches()
  bbp_get_global_post_field()
  bbp_verify_nonce_request()
  bbp_request_feed_trap()
  bbp_get_page_by_path()
  bbp_set_404()
  bbp_set_200()
  bbp_pre_handle_404()
  bbp_posts_pre_query()
  bbp_get_url_scheme()
  bbp_is_title_too_long()

Functions
Functions that are not part of a class:

bbp_get_post_types( $args = array()   X-Ref
Return array of bbPress registered post types

param: array $args Array of arguments to pass into `get_post_types()`
since: 2.6.0 bbPress (r6813)
return: array

bbp_get_redirect_to()   X-Ref
Return the unescaped redirect_to request value

return: string The URL to redirect to, if set

bbp_add_view_all( $original_link = '', $force = false )   X-Ref
Append 'view=all' to query string if it's already there from referer

param: string $original_link Original Link to be modified
param: bool $force Override bbp_get_view_all() check
since: 2.0.0 bbPress (r3325)
return: string The link with 'view=all' appended if necessary

bbp_remove_view_all( $original_link = '' )   X-Ref
Remove 'view=all' from query string

param: string $original_link Original Link to be modified
since: 2.0.0 bbPress (r3325)
return: string The link with 'view=all' appended if necessary

bbp_get_view_all( $cap = 'moderate' )   X-Ref
If current user can and is viewing all topics/replies

param: string $cap Capability used to ensure user can view all
since: 2.0.0 bbPress (r3325)
return: bool Whether current user can and is viewing all

bbp_get_paged()   X-Ref
Assist pagination by returning correct page number

since: 2.0.0 bbPress (r2628)
return: int Current page number

bbp_get_unique_array_values( $array = array()   X-Ref
Return the unique non-empty values of an array.

param: array $array Array to get values of
since: 2.6.0 bbPress (r6481)
return: array

bbp_fix_post_author( $data = array()   X-Ref
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.

param: array $data Post data
param: array $postarr Original post array (includes post id)
since: 2.0.0 bbPress (r2734)
return: array Data

bbp_past_edit_lock( $datetime = '', $utc = true )   X-Ref
Check a date against the length of time something can be edited.

It is recommended to leave $utc set to true and to work with UTC/GMT dates.
Turning this off will use the WordPress offset which is likely undesirable.

param: string  $datetime Gets run through strtotime()
param: boolean $utc      Default true. Is the timestamp in UTC?
since: 2.0.0 bbPress (r3133)
since: 2.6.0 bbPress (r6868) Inverted some logic and added unit tests
return: bool True by default, if date is past, or editing is disabled.

bbp_get_trash_days( $context = 'forum' )   X-Ref
Get number of days something should remain trashed for before it is cleaned
up by WordPress Cron. If set to 0, items will skip trash and be deleted
immediately.

param: string $context Provide context for additional filtering
since: 2.6.0 bbPress (r6424)
return: int Number of days items remain in trash

bbp_get_statistics( $args = array()   X-Ref
Get the forum statistics

param: array $args Optional. The function supports these arguments (all
since: 2.0.0 bbPress (r2769)
since: 2.6.0 bbPress (r6055) Introduced the `count_pending_topics` and
return: object Walked forum tree

bbp_filter_anonymous_post_data( $args = array()   X-Ref
Filter anonymous post data

We use REMOTE_ADDR here directly. If you are behind a proxy, you should
ensure that it is properly set, such as in wp-config.php, for your
environment. See {@link https://core.trac.wordpress.org/ticket/9235}

Note that bbp_pre_anonymous_filters() is responsible for sanitizing each
of the filtered core anonymous values here.

If there are any errors, those are directly added to {@link bbPress:errors}

param: array $args Optional. If no args are there, then $_POST values are
since: 2.0.0 bbPress (r2734)
return: bool|array False on errors, values in an array on success

bbp_sanitize_anonymous_post_author( $anonymous_data = array()   X-Ref
Sanitize an array of anonymous post author data

param: array $anonymous_data
since: 2.6.0 bbPress (r6400)
return: array

bbp_update_anonymous_post_author( $post_id = 0, $anonymous_data = array()   X-Ref
Update the relevant meta-data for an anonymous post author

param: int    $post_id
param: array  $anonymous_data
param: string $post_type
since: 2.6.0 bbPress (r6400)

bbp_check_for_duplicate( $post_data = array()   X-Ref
Check for duplicate topics/replies

Check to make sure that a user is not making a duplicate post

param: array $post_data Contains information about the comment
since: 2.0.0 bbPress (r2763)
return: bool True if it is not a duplicate, false if it is

bbp_check_for_flood( $anonymous_data = array()   X-Ref
Check for flooding

Check to make sure that a user is not making too many posts in a short amount
of time.

param: array $anonymous_data Optional - if it's an anonymous post. Do not
param: int $author_id Optional. Supply if it's a post by a logged in user.
since: 2.0.0 bbPress (r2734)
return: bool True if there is no flooding, false if there is

bbp_check_for_moderation( $anonymous_data = array()   X-Ref
Checks topics and replies against the discussion moderation of blocked keys

param: array $anonymous_data Optional - if it's an anonymous post. Do not
param: int $author_id Topic or reply author ID
param: string $title The title of the content
param: string $content The content being posted
param: mixed  $strict  False for moderation_keys. True for blacklist_keys.
since: 2.1.0 bbPress (r3581)
return: bool True if test is passed, false if fail

bbp_check_for_blacklist( $anonymous_data = array()   X-Ref
Deprecated. Use bbp_check_for_moderation() with strict flag set.

since: 2.0.0 bbPress (r3446)
since: 2.6.0 bbPress (r6854)

bbp_get_do_not_reply_address()   X-Ref
Get the "Do Not Reply" email address to use when sending subscription emails.

We make some educated guesses here based on the home URL. Filters are
available to customize this address further. In the future, we may consider
using `admin_email` instead, though this is not normally publicized.

We use `$_SERVER['SERVER_NAME']` here to mimic similar functionality in
WordPress core. Previously, we used `get_home_url()` to use already validated
user input, but it was causing issues in some installations.

since: 2.6.0 bbPress (r5409)
return: string

bbp_notify_topic_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = array()   X-Ref
Sends notification emails for new replies to subscribed topics

Gets new post ID and check if there are subscribed users to that topic, and
if there are, send notifications

Note: in bbPress 2.6, we've moved away from 1 email per subscriber to 1 email
with everyone BCC'd. This may have negative repercussions for email services
that limit the number of addresses in a BCC field (often to around 500.) In
those cases, we recommend unhooking this function and creating your own
custom email script.

param: int $reply_id ID of the newly made reply
param: int $topic_id ID of the topic of the reply
param: int $forum_id ID of the forum of the reply
param: array $anonymous_data Optional - if it's an anonymous post. Do not
param: int $reply_author ID of the topic author ID
since: 2.6.0 bbPress (r5413)
return: bool True on success, false on failure

bbp_notify_forum_subscribers( $topic_id = 0, $forum_id = 0, $anonymous_data = array()   X-Ref
Sends notification emails for new topics to subscribed forums

Gets new post ID and check if there are subscribed users to that forum, and
if there are, send notifications

Note: in bbPress 2.6, we've moved away from 1 email per subscriber to 1 email
with everyone BCC'd. This may have negative repercussions for email services
that limit the number of addresses in a BCC field (often to around 500.) In
those cases, we recommend unhooking this function and creating your own
custom email script.

param: int $topic_id ID of the newly made reply
param: int $forum_id ID of the forum for the topic
param: array $anonymous_data Optional - if it's an anonymous post. Do not
param: int $topic_author ID of the topic author ID
since: 2.5.0 bbPress (r5156)
return: bool True on success, false on failure

bbp_notify_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = array()   X-Ref
Sends notification emails for new replies to subscribed topics

This function is deprecated. Please use: bbp_notify_topic_subscribers()

param: int $reply_id ID of the newly made reply
param: int $topic_id ID of the topic of the reply
param: int $forum_id ID of the forum of the reply
param: array $anonymous_data Optional - if it's an anonymous post. Do not
param: int $reply_author ID of the topic author ID
since: 2.0.0 bbPress (r2668)
return: bool True on success, false on failure

bbp_get_email_addresses_from_user_ids( $user_ids = array()   X-Ref
Return an array of user email addresses from an array of user IDs

param: array $user_ids
since: 2.6.0 bbPress (r6722)
return: array

bbp_logout_url( $url = '', $redirect_to = '' )   X-Ref
Return a clean and reliable logout URL

This function is used to filter `logout_url`. If no $redirect_to value is
passed, it will default to the request uri, then the forum root.

See: `wp_logout_url()`

param: string $url URL used to log out
param: string $redirect_to Where to redirect to?
since: 2.1.0 bbPress (2815)
return: string The url

bbp_parse_args( $args, $defaults = array()   X-Ref
Merge user defined arguments into defaults array.

This function is used throughout bbPress to allow for either a string or array
to be merged into another array. It is identical to wp_parse_args() except
it allows for arguments to be passively or aggressively filtered using the
optional $filter_key parameter.

param: string|array $args Value to merge with $defaults
param: array $defaults Array that serves as the defaults.
param: string $filter_key String to key the filters from
since: 2.1.0 bbPress (r3839)
return: array Merged user defined values with defaults.

bbp_query_post_parent__in( $where, $object = '' )   X-Ref
Adds ability to include or exclude specific post_parent ID's

param: string $where
param: WP_Query $object
since: 2.0.0 bbPress (r2996)
return: string

bbp_get_public_child_last_id( $parent_id = 0, $post_type = 'post' )   X-Ref
Query the DB and get the last public post_id that has parent_id as post_parent

param: int    $parent_id Parent id.
param: string $post_type Post type. Defaults to 'post'.
since: 2.0.0 bbPress (r2868)
since: 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects
return: int The last active post_id

bbp_get_child_counts( $parent_id = 0 )   X-Ref
Query the database for child counts, grouped by type & status

param: int $parent_id
since: 2.6.0 bbPress (r6826)

bbp_filter_child_counts_list( $parent_id = 0, $types = array( 'post' )   X-Ref
Filter a list of child counts, from `bbp_get_child_counts()`

param: int    $parent_id  ID of post to get child counts from
param: array  $types      Optional. An array of post types to filter by
param: array  $statuses   Optional. An array of post statuses to filter by
since: 2.6.0 bbPress (r6826)
return: array A list of objects or object fields.

bbp_get_public_child_count( $parent_id = 0, $post_type = 'post' )   X-Ref
Query the DB and get a count of public children

param: int    $parent_id Parent id.
param: string $post_type Post type. Defaults to 'post'.
since: 2.0.0 bbPress (r2868)
since: 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects
return: int The number of children

bbp_get_non_public_child_count( $parent_id = 0, $post_type = 'post' )   X-Ref
Query the DB and get a count of public children

param: int    $parent_id Parent id.
param: string $post_type Post type. Defaults to 'post'.
since: 2.0.0 bbPress (r2868)
since: 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects
return: int The number of children

bbp_get_public_child_ids( $parent_id = 0, $post_type = 'post' )   X-Ref
Query the DB and get the child id's of public children

param: int    $parent_id Parent id.
param: string $post_type Post type. Defaults to 'post'.
since: 2.0.0 bbPress (r2868)
since: 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects
return: array The array of children

bbp_get_all_child_ids( $parent_id = 0, $post_type = 'post' )   X-Ref
Query the DB and get the child id's of all children

param: int $parent_id  Parent id
param: string $post_type Post type. Defaults to 'post'
since: 2.0.0 bbPress (r3325)
return: array The array of children

bbp_update_post_family_caches( $objects = array()   X-Ref
Prime familial post caches.

This function uses _prime_post_caches() to prepare the object cache for
imminent requests to post objects that aren't naturally cached by the primary
WP_Query calls themselves. Post author caches are also primed.

This is triggered when a `update_post_family_cache` argument is set to true.

Also see: bbp_update_post_author_caches()

param: array $objects Array of objects, fresh from a query
since: 2.6.0 bbPress (r6699)
return: bool True if some IDs were cached

bbp_update_post_author_caches( $objects = array()   X-Ref
Prime post author caches.

This function uses cache_users() to prepare the object cache for
imminent requests to user objects that aren't naturally cached by the primary
WP_Query calls themselves.

This is triggered when a `update_post_author_cache` argument is set to true.

param: array $objects Array of objects, fresh from a query
since: 2.6.0 bbPress (r6699)
return: bool True if some IDs were cached

bbp_get_global_post_field( $field = 'ID', $context = 'edit' )   X-Ref
Get the unfiltered value of a global $post's key

Used most frequently when editing a forum/topic/reply

param: string $field Name of the key
param: string $context How to sanitize - raw|edit|db|display|attribute|js
since: 2.1.0 bbPress (r3694)
return: string Field value

bbp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' )   X-Ref
Makes sure the user requested an action from another page on this site.

To avoid security exploits within the theme.

param: string $action Action nonce
param: string $query_arg where to look for nonce in $_REQUEST
since: 2.1.0 bbPress (r4022)

bbp_request_feed_trap( $query_vars = array()   X-Ref
This function is hooked into the WordPress 'request' action and is
responsible for sniffing out the query vars and serving up RSS2 feeds if
the stars align and the user has requested a feed of any bbPress type.

param: array $query_vars
since: 2.0.0 bbPress (r3171)
return: array

bbp_get_page_by_path( $path = '' )   X-Ref
Used to guess if page exists at requested path

param: string $path
since: 2.0.0 bbPress (r3304)
return: mixed False if no page, Page object if true

bbp_set_404( $query = null )   X-Ref
Sets the 404 status.

Used primarily with topics/replies inside hidden forums.

param: WP_Query $query  The query being checked
since: 2.0.0 bbPress (r3051)
since: 2.6.0 bbPress (r6583) Use status_header() & nocache_headers()
return: bool Always returns true

bbp_set_200()   X-Ref
Sets the 200 status header.

since: 2.6.0 bbPress (r6583)

bbp_pre_handle_404( $override = false, $wp_query = false )   X-Ref
Maybe handle the default 404 handling for some bbPress conditions

Some conditions (like private/hidden forums and edits) have their own checks
on `bbp_template_redirect` and are not currently 404s.

param: bool $override Whether to override the default handler
param: WP_Query $wp_query The posts query being referenced
since: 2.6.0 bbPress (r6555)
return: bool False to leave alone, true to override

bbp_posts_pre_query( $posts = null, $wp_query = false )   X-Ref
Maybe pre-assign the posts that are returned from a WP_Query.

This effectively short-circuits the default query for posts, which is
currently only used to avoid calling the main query when it's not necessary.

param: mixed $posts Default null. Array of posts (possibly empty)
param: WP_Query $wp_query
since: 2.6.0 bbPress (r6580)
return: mixed Null if no override. Array if overridden.

bbp_get_url_scheme()   X-Ref
Get scheme for a URL based on is_ssl() results.

since: 2.6.0 bbPress (r6759)
return: string https:// if is_ssl(), otherwise http://

bbp_is_title_too_long( $title = '' )   X-Ref
Is a title longer that the maximum title length?

Uses mb_strlen() in `8bit` mode to treat strings as raw. This matches the
behavior present in Comments, PHPMailer, RandomCompat, and others.

param: string $title
since: 2.6.0 bbPress (r6783)
return: bool



Generated: Mon Jul 22 01:01:32 2019 Cross-referenced by PHPXref 0.7.1