Confetti Bits

Core

Table of Contents

Packages

Templates

Classes

TeamCTG_User_Caps
CB_Component
CB Component
CB_Core_Role_Manager
CB Core Roles Component
CB_Core_Role
CB Core Roles Component

Functions

cb_core_admin_setting_general_register_fields()  : mixed
CB Core Admin Settings General Register Fields
cb_core_admin_components_settings()  : mixed
cb_admin_components_options()  : mixed
cb_core_set_role_globals()  : mixed
Sets some useful globals for specialized roles for later use.
cb_core_add_admin_caps()  : mixed
Grants all capabilities to administrator users.
cb_core_current_user_can()  : bool
An alias for current_user_can()
cb_core_is_component_admin()  : bool
Checks whether a user is an admin of the given component.
cb_is_user_admin()  : bool
Checks whether user has certain administrative privileges.
cb_is_user_executive()  : mixed
Checks to see if the user is an executive user.
cb_is_user_site_admin()  : bool
Checks if the user has site admin privileges.
cb_core_admin_is_user_site_admin()  : bool
CB Core Admin Is User Site Admin
cb_core_admin_is_user_admin()  : bool
Checks whether a user has the cb_admin capability.
cb_is_user_participation_admin()  : bool
Checks to see if the user is a participation admin.
cb_is_user_requests_admin()  : bool
Checks to see if the user is a requests admin.
cb_is_user_staffing_admin()  : bool
Checks to see if the user is a staffing admin.
cb_is_user_events_admin()  : bool
Checks to see if the user is an events admin.
editor_manage_users()  : mixed
Let Editors manage users, and run this only once.
get_rid_of_the_menus()  : mixed
Remove privileged menus from the admin area.
cb_core_set_uri_globals()  : mixed
Sets a global based on the current URI.
cb_is_current_component()  : bool
Does an entire song and dance to see if this is the component you want.
cb_is_confetti_bits_component()  : bool
Asks the wizard if we could have some porridge.
cb_is_user()  : mixed
Checks whether there is a currently logged-in user.
cb_is_user_confetti_bits()  : bool
Checks to see if we're in the land of wonder.
cb_core_get_active_components()  : array<string|int, mixed>
Gives us an array of all active components.
cb_admin_enqueue_scripts()  : mixed
Fires the cb_admin_enqueue_scripts action, where plugins can enqueue admin scripts.
cb_loaded()  : mixed
Fires the cb_loaded action, where plugins can load their files.
cb_init()  : mixed
Fires the cb_init action, where plugins can initialize their components.
cb_customize_register()  : mixed
Fires the cb_customize_register action, where plugins can register their customizer settings.
cb_ready()  : mixed
Fires the cb_ready action, where plugins can do things after the CB plugin is ready.
cb_setup_current_user()  : mixed
Fires the cb_setup_current_user action, where plugins can do things after the current user is setup.
cb_setup_theme()  : mixed
Fires the cb_setup_theme action, where plugins can modify what happens while the theme is being setup.
cb_after_setup_theme()  : mixed
Fires the cb_after_setup_theme action, where plugins can do things after the theme is setup.
cb_enqueue_scripts()  : mixed
Fires the cb_enqueue_scripts action, where plugins can register their front-end scripts.
cb_template_redirect()  : mixed
Fires the cb_template_redirect action, where plugins can do things before the template is loaded.
cb_widgets_init()  : mixed
Fires the cb_widgets_init action, where plugins can register their widgets.
cb_generate_rewrite_rules()  : mixed
Fires the cb_generate_rewrite_rules action, where plugins can add their rewrite rules.
cb_setup_components()  : mixed
Fires the cb_setup_components action, where plugins can register their components.
cb_include()  : mixed
Fires the cb_include action, where plugins can include their files.
cb_register_post_types()  : mixed
Fires the cb_register_post_types action, where plugins can register their post types.
cb_register_taxonomies()  : mixed
Fires the cb_register_taxonomies action, where plugins can register their taxonomies.
cb_setup_globals()  : mixed
Fires the cb_setup_globals action, where plugins can register their globals.
cb_setup_canonical_stack()  : mixed
Fires the cb_setup_canonical_stack action, where plugins can register their canonical stack.
cb_setup_nav()  : mixed
Fires the cb_setup_nav action, where plugins can register their nav items.
cb_setup_title()  : mixed
Fires the cb_setup_title action, where plugins can register their title.
cb_add_rewrite_tags()  : mixed
Fires the cb_add_rewrite_tags action, where plugins can add their rewrite tags.
cb_add_rewrite_rules()  : mixed
Fires the cb_add_rewrite_rules action, where plugins can add their rewrite rules.
cb_add_permastructs()  : mixed
Fires the cb_add_permastructs action, where plugins can add their permastructs.
cb_register_member_types()  : mixed
Fires the cb_register_member_types action, where plugins can register their member types.
cb_actions()  : mixed
Fires the cb_actions action, where plugins can register their actions.
cb_screens()  : mixed
Fires the cb_screens action, where plugins can register their screens.
cb_late_include()  : mixed
Fires the cb_late_include action, where plugins can add include files after the canonical stack has been established.
cb_post_request()  : mixed
Fires the cb_post_request action, where plugins can register their post requests.
cb_head()  : mixed
Fires the cb_head action, where plugins can register their head items.
cb_template_include()  : mixed
Fires the cb_template_include action, where plugins can modify the template.
cb_allowed_themes()  : mixed
Fires the cb_allowed_themes action, where plugins can modify the allowed themes.
cb_rest_api_init()  : mixed
Fires the cb_rest_api_init action, so we (and others) can easily hook into our REST API.
cb_core_install_events()  : mixed
CB Core Install Events
cb_core_install_spot_bonuses()  : mixed
Installs our spot bonus table on the database.
cb_core_install_transactions()  : mixed
CB Core Install Transactions
cb_core_install_participation()  : mixed
CB Core Install Participation
cb_core_install_contests()  : mixed
CB Core Install Contests
cb_core_install_request_items()  : mixed
CB Core Install Request Items
cb_core_install_requests()  : mixed
CB Core Install Requests
cb_core_prepare_install()  : mixed
Put stuff here that you want to run before installation.
cb_core_install()  : mixed
Installs all our tables on the database.
cb_setup_core()  : mixed
Sets up our Core component, which loads all of our other components.
cb_core_generate_uuid()  : string
CB Core Generate UUID
cb_core_get_api_key()  : string
CB Core Get API Key
cb_core_secrets_manager_init()  : string
CB Core Secrets Manager Init
cb_core_update_api_key()  : string
CB Core Update API Key
cb_core_validate_api_key()  : bool
Validates against a supplied API key safe name.
cb_member_template_part()  : mixed
Renders the member template part appropriate for the current page.
Confetti_Bits()  : Confetti_Bits
The main function responsible for returning the one true Confetti_Bits
cb_plugin_init()  : void
Init the plugin.
cb_is_patch_request()  : bool
CB Is Patch Request
cb_is_delete_request()  : bool
CB Is Delete Request
cb_core_notifications_init()  : mixed
Initializes our notifications class.
cb_user_birthday_anniversary_fields()  : mixed
Returns form markup that allows privileged users to manually input the birthday and anniversary dates for other users.
cb_core_set_reset_date_globals()  : mixed
CB Core Set Reset Date Globals
cb_core_set_spot_bonus_global()  : mixed
Sets the amount for spot bonuses in our core class for easy access.
cb_core_auto_reset()  : mixed
Automatically increments the reset date by 1 year.
cb_core_current_date()  : string
CB Core Current Date
str_starts_with()  : bool
Str Starts With
str_ends_with()  : bool
Str Ends With
str_contains()  : bool
Str Contains
cb_flush_rewrite_rules()  : mixed
CB Flush Rewrite Rules
cb_get_patch_data()  : array<string|int, mixed>
Gets PATCH data from an HTTP PATCH request.
cb_get_delete_data()  : array<string|int, mixed>
Gets DELETE data from an HTTP DELETE request.
cb_core_get_missing_users()  : array<string|int, mixed>
Gets a list of transactions for nonexistent users.
cb_core_get_user_display_name()  : string
Gets the user display name.
cb_core_get_user_email()  : string
Returns the email address for the given user.
cb_core_is_multi_array()  : bool
Checks if the parameter is a multi-dimensional array.
cb_core_send_sitewide_notice()  : mixed
Sends out a sitewide notice.
cb_core_get_doomsday_clock()  : int
Returns the number of days remaining until the reset date.
cb_core_sanitize_string()  : string
Washes away the sins of bad actors.
cb_core_smtp_init()  : mixed
Injects our own config settings into PHPMailer.
cb_core_delete_user_data()  : mixed
Deletes all Confetti Bits data associated with deleted user.
cb_core_ordinal_suffix()  : string
Adds an ordinal suffix to a given integer.

Functions

cb_core_admin_setting_general_register_fields()

CB Core Admin Settings General Register Fields

cb_core_admin_setting_general_register_fields(mixed $setting) : mixed

Registers our settings fields in the general context of the BuddyBoss settings page environment. Key part of this is the "bp_admin_setting_{ component }_register_fields" add_section is a wordpress method to create the settings section. It requires a setting object. add_field is a wordpress method that creates a field within the section we just made. bp_admin_setting_{ component }_register_fields handles the rest.

Parameters
$setting : mixed
Tags
since
1.0.0

cb_core_admin_components_settings()

cb_core_admin_components_settings() : mixed

cb_admin_components_options()

cb_admin_components_options() : mixed

cb_core_set_role_globals()

Sets some useful globals for specialized roles for later use.

cb_core_set_role_globals() : mixed

The idea here is that once these globals are set, we can access them to grant certain permissions to certain roles, which will help us determine who can see what in our template loop.

Tags
since
3.0.0

cb_core_add_admin_caps()

Grants all capabilities to administrator users.

cb_core_add_admin_caps() : mixed
Tags
since
3.0.0

cb_core_current_user_can()

An alias for current_user_can()

cb_core_current_user_can([string $cap = '' ]) : bool
Parameters
$cap : string = ''

The capability to check for.

Tags
since
3.0.0
Return values
bool

Whether the user has the capability.

cb_core_is_component_admin()

Checks whether a user is an admin of the given component.

cb_core_is_component_admin([string $component = '' ]) : bool
Parameters
$component : string = ''

The component to check for.

Tags
since
3.0.0
Return values
bool

Whether the user is an admin for the component.

cb_is_user_admin()

Checks whether user has certain administrative privileges.

cb_is_user_admin([mixed $user_id = 0 ]) : bool

These include: - cb_participation_admin - cb_events_admin - cb_requests_admin

It's important to note that the cb_admin capability is shared by both the cb_leadership role as well as the cb_executive role, so checking for this capability will return true for both of those roles, along with users that have the 'administrator' capability.

Parameters
$user_id : mixed = 0
Tags
since
1.0.0
Return values
bool

Whether the current user is a cb_admin.

cb_is_user_executive()

Checks to see if the user is an executive user.

cb_is_user_executive() : mixed

This role carries specific, high-level privileges in certain areas of the application, so it exists as its own separate capability.

Tags
since
1.3.0

cb_is_user_site_admin()

Checks if the user has site admin privileges.

cb_is_user_site_admin([mixed $user_id = 0 ]) : bool

Checks whether a user has administrative privileges. Also, @see cb_core_admin_is_user_site_admin(), because we're deprecating this for the sake of our API and sanity (sorry besties).

Parameters
$user_id : mixed = 0
Tags
TODO:

Figure out a better dev environment setup; this isn't particularly good to use as a feature-blocker.

since
1.0.0
Return values
bool

Whether a user has administrative privileges.

cb_core_admin_is_user_site_admin()

CB Core Admin Is User Site Admin

cb_core_admin_is_user_site_admin([mixed $user_id = 0 ]) : bool

Checks whether a user has administrative privileges.

Parameters
$user_id : mixed = 0
Tags
TODO:

Figure out a better dev environment setup; this isn't particularly good to use as a feature-blocker.

since
2.3.0
Return values
bool

Whether a user has administrative privileges.

cb_core_admin_is_user_admin()

Checks whether a user has the cb_admin capability.

cb_core_admin_is_user_admin([mixed $user_id = 0 ]) : bool
Parameters
$user_id : mixed = 0
Tags
since
2.3.1
Return values
bool

Whether a user has cb_admin privileges.

cb_is_user_participation_admin()

Checks to see if the user is a participation admin.

cb_is_user_participation_admin() : bool

Checks whether a user has administrative privileges over the participation component. These privileges are granted by assigning a role on the Edit User admin page.

Tags
since
1.0.0
Return values
bool

Whether a user is a participation admin.

cb_is_user_requests_admin()

Checks to see if the user is a requests admin.

cb_is_user_requests_admin() : bool

Checks whether a user has administrative privileges over the requests component. These privileges are granted by assigning a role on the Edit User admin page.

Tags
since
3.0.0
Return values
bool

Whether a user is a requests admin.

cb_is_user_staffing_admin()

Checks to see if the user is a staffing admin.

cb_is_user_staffing_admin() : bool

Checks whether a user has administrative privileges for user moderation. These privileges are granted by assigning a role on the Edit User admin page.

Tags
since
1.0.0
Return values
bool

Whether a user is a staffing admin.

cb_is_user_events_admin()

Checks to see if the user is an events admin.

cb_is_user_events_admin() : bool

Checks whether a user has administrative privileges over the events component. These privileges are granted by assigning a role on the Edit User admin page.

Tags
since
2.3.0
Return values
bool

Whether a user is an events admin.

editor_manage_users()

Let Editors manage users, and run this only once.

editor_manage_users() : mixed

Version: 1.0.0

get_rid_of_the_menus()

Remove privileged menus from the admin area.

get_rid_of_the_menus() : mixed
Tags
since
1.2.0

cb_core_set_uri_globals()

Sets a global based on the current URI.

cb_core_set_uri_globals() : mixed

The goal here at one point was to have each component dynamically registered through the URI and accessible via a stacking path, like this:

https://{{domain}}/{{component}}/{{action}}/{{item}}

This is no easy feat. It would also require some significant shenanigans on our end to make that happen. So we've opted to using REST API endpoints, and just checking whether $cb->current_component exists, and is indeed === 'confetti-bits'.

Tags
since
1.0.0

cb_is_current_component()

Does an entire song and dance to see if this is the component you want.

cb_is_current_component([string $component = '' ]) : bool
  1. Checks to see if the current component is the same as the supplied component.
  2. Checks to see if the supplied component has a slug that matches.
  3. Checks to see if the supplied component is in the array of active components.
  4. Checks one last time to see if any of the active components has a slug that matches the supplied component.
Parameters
$component : string = ''

The component to check for.

Tags
since
1.0.0
Return values
bool

True if it's one of ours, false in any other scenario.

cb_is_confetti_bits_component()

Asks the wizard if we could have some porridge.

cb_is_confetti_bits_component() : bool
Tags
since
1.0.0
Return values
bool

Whether we may have some porridge.

cb_is_user_confetti_bits()

Checks to see if we're in the land of wonder.

cb_is_user_confetti_bits() : bool
Tags
since
1.0.0
Return values
bool

Whether we're in the land of wonder.

cb_core_get_active_components()

Gives us an array of all active components.

cb_core_get_active_components() : array<string|int, mixed>
Tags
since
3.0.0
Return values
array<string|int, mixed>

Active components.

cb_admin_enqueue_scripts()

Fires the cb_admin_enqueue_scripts action, where plugins can enqueue admin scripts.

cb_admin_enqueue_scripts() : mixed
Tags
since
1.0.0

cb_loaded()

Fires the cb_loaded action, where plugins can load their files.

cb_loaded() : mixed
Tags
since
1.0.0

cb_init()

Fires the cb_init action, where plugins can initialize their components.

cb_init() : mixed
Tags
since
1.0.0

cb_customize_register()

Fires the cb_customize_register action, where plugins can register their customizer settings.

cb_customize_register(WP_Customize_Manager $customizer) : mixed
Parameters
$customizer : WP_Customize_Manager
Tags
since
1.0.0

cb_ready()

Fires the cb_ready action, where plugins can do things after the CB plugin is ready.

cb_ready() : mixed
Tags
since
1.0.0

cb_setup_current_user()

Fires the cb_setup_current_user action, where plugins can do things after the current user is setup.

cb_setup_current_user() : mixed
Tags
since
1.0.0

cb_setup_theme()

Fires the cb_setup_theme action, where plugins can modify what happens while the theme is being setup.

cb_setup_theme() : mixed
Tags
since
1.0.0

cb_after_setup_theme()

Fires the cb_after_setup_theme action, where plugins can do things after the theme is setup.

cb_after_setup_theme() : mixed
Tags
since
1.0.0

cb_enqueue_scripts()

Fires the cb_enqueue_scripts action, where plugins can register their front-end scripts.

cb_enqueue_scripts() : mixed
Tags
since
1.0.0

cb_template_redirect()

Fires the cb_template_redirect action, where plugins can do things before the template is loaded.

cb_template_redirect() : mixed
Tags
since
1.0.0

cb_widgets_init()

Fires the cb_widgets_init action, where plugins can register their widgets.

cb_widgets_init() : mixed
Tags
since
1.0.0

cb_generate_rewrite_rules()

Fires the cb_generate_rewrite_rules action, where plugins can add their rewrite rules.

cb_generate_rewrite_rules(mixed $wp_rewrite) : mixed
Parameters
$wp_rewrite : mixed
Tags
since
1.0.0

cb_setup_components()

Fires the cb_setup_components action, where plugins can register their components.

cb_setup_components() : mixed
Tags
since
1.0.0

cb_include()

Fires the cb_include action, where plugins can include their files.

cb_include() : mixed
Tags
since
1.0.0

cb_register_post_types()

Fires the cb_register_post_types action, where plugins can register their post types.

cb_register_post_types() : mixed
Tags
since
1.0.0

cb_register_taxonomies()

Fires the cb_register_taxonomies action, where plugins can register their taxonomies.

cb_register_taxonomies() : mixed
Tags
since
1.0.0

cb_setup_globals()

Fires the cb_setup_globals action, where plugins can register their globals.

cb_setup_globals() : mixed
Tags
since
1.0.0

cb_setup_canonical_stack()

Fires the cb_setup_canonical_stack action, where plugins can register their canonical stack.

cb_setup_canonical_stack() : mixed
Tags
since
1.0.0

cb_setup_nav()

Fires the cb_setup_nav action, where plugins can register their nav items.

cb_setup_nav() : mixed
Tags
since
1.0.0

cb_setup_title()

Fires the cb_setup_title action, where plugins can register their title.

cb_setup_title() : mixed
Tags
since
1.0.0

cb_add_rewrite_tags()

Fires the cb_add_rewrite_tags action, where plugins can add their rewrite tags.

cb_add_rewrite_tags() : mixed
Tags
since
1.0.0

cb_add_rewrite_rules()

Fires the cb_add_rewrite_rules action, where plugins can add their rewrite rules.

cb_add_rewrite_rules() : mixed
Tags
since
1.0.0

cb_add_permastructs()

Fires the cb_add_permastructs action, where plugins can add their permastructs.

cb_add_permastructs() : mixed
Tags
since
1.0.0

cb_register_member_types()

Fires the cb_register_member_types action, where plugins can register their member types.

cb_register_member_types() : mixed
Tags
since
1.0.0

cb_actions()

Fires the cb_actions action, where plugins can register their actions.

cb_actions() : mixed
Tags
since
1.0.0

cb_screens()

Fires the cb_screens action, where plugins can register their screens.

cb_screens() : mixed
Tags
since
1.0.0

cb_late_include()

Fires the cb_late_include action, where plugins can add include files after the canonical stack has been established.

cb_late_include() : mixed
Tags
since
1.0.0

cb_post_request()

Fires the cb_post_request action, where plugins can register their post requests.

cb_post_request() : mixed
Tags
since
1.0.0

cb_head()

Fires the cb_head action, where plugins can register their head items.

cb_head() : mixed
Tags
since
1.0.0

cb_template_include()

Fires the cb_template_include action, where plugins can modify the template.

cb_template_include([string $template = '' ]) : mixed
Parameters
$template : string = ''

The template to include.

Tags
since
1.0.0

cb_allowed_themes()

Fires the cb_allowed_themes action, where plugins can modify the allowed themes.

cb_allowed_themes(array<string|int, mixed> $themes) : mixed
Parameters
$themes : array<string|int, mixed>

The allowed themes.

Tags
since
1.0.0

cb_rest_api_init()

Fires the cb_rest_api_init action, so we (and others) can easily hook into our REST API.

cb_rest_api_init() : mixed
Tags
since
2.3.0

cb_core_prepare_install()

Put stuff here that you want to run before installation.

cb_core_prepare_install() : mixed
Tags
since
1.0.0

cb_setup_core()

Sets up our Core component, which loads all of our other components.

cb_setup_core() : mixed
Tags
since
1.0.0

cb_core_generate_uuid()

CB Core Generate UUID

cb_core_generate_uuid([mixed $bytes = 32 ]) : string

Generates a UUID that we can use to create unique keys and other neat things for API validation and the like. "Cryptographically secure", unless someone is using a quantum computer. In which case... you're really picking this program as the thing you want to hack? Really?

Parameters
$bytes : mixed = 32
Tags
since
2.3.0
Return values
string

An RFC 4211 compliant universally unique identifier.

cb_core_get_api_key()

CB Core Get API Key

cb_core_get_api_key([mixed $secret = '' ]) : string

Pulls the API key from our secrets manager. You may wanna study up on AWS!

Parameters
$secret : mixed = ''
Tags
since
2.3.0
Return values
string

The API key. Use with caution, share with none.

cb_core_secrets_manager_init()

CB Core Secrets Manager Init

cb_core_secrets_manager_init() : string

Creates our first set of API credentials automatically. Can refresh them at any time via WordPress admin panel.

Tags
TODO:

Add the aforementioned WordPress admin panel.

since
2.3.0
Return values
string

The stringified Model data, or error message on failure.

cb_core_update_api_key()

CB Core Update API Key

cb_core_update_api_key() : string

Creates a new API key in our secrets manager and updates its safe name in the options table.

Tags
since
2.3.0
Return values
string

The stringified Model data, or error message on failure.

cb_core_validate_api_key()

Validates against a supplied API key safe name.

cb_core_validate_api_key([string $safe_name = '' ]) : bool

We work with safe names here. We store the safe name in our DB, and that works as the current valid API key for the current website. If the safe name that gets supplied does not match our safe name, it will fail the test. If the supplied safe name matches, it will then search our secrets manager for a valid API key. If one is not found, or it is expired or invalid, it will also fail.

Parameters
$safe_name : string = ''

The safe name for our API key.

Tags
since
2.3.0
Return values
bool

Whether the API key exists and is valid.

cb_member_template_part()

Renders the member template part appropriate for the current page.

cb_member_template_part() : mixed

Right now? We only have the one page. Oof.

Tags
since
1.0.0

cb_plugin_init()

Init the plugin.

cb_plugin_init() : void
Tags
since
1.0.0

cb_is_patch_request()

CB Is Patch Request

cb_is_patch_request() : bool

Checks if the current request is a PATCH request

Tags
since
2.3.0
Return values
bool

True if PATCH request, false otherwise

cb_is_delete_request()

CB Is Delete Request

cb_is_delete_request() : bool

Checks if the current request is a DELETE request

Tags
since
2.3.0
Return values
bool

True if DELETE request, false otherwise

cb_core_notifications_init()

Initializes our notifications class.

cb_core_notifications_init() : mixed

So we can get those sweet, sweet noties.

Tags
since
1.3.0

cb_user_birthday_anniversary_fields()

Returns form markup that allows privileged users to manually input the birthday and anniversary dates for other users.

cb_user_birthday_anniversary_fields(mixed $user) : mixed
Parameters
$user : mixed
Tags
since
3.0.0

cb_core_set_reset_date_globals()

CB Core Set Reset Date Globals

cb_core_set_reset_date_globals() : mixed

Sets a few internal globals using the DateTimeImmutable class so that we can reference these spending/earning cycles throughout the app without running these calculations all the time.

A breakdown of what this does:

  • There are two cycles: an earning cycle and a spending cycle

  • The reset date refers to the earning cycle. That is when users start over with a zero'd out bank of confetti bits. So the earning cycle "ends" on the reset date.

  • The earning cycle "starts" one year prior to that, on the same date. Please don't set it to February 29th, I did not account for that when I built this forsaken system.

  • The spending cycle is offset by 1 month after the earning cycle. So the spending cycle "ends" 1 month after the earning cycle does. That means that the spending cycle "starts" one month after the earning cycle does as well.

  • There are situations where a user may want to look back at a previous cycle, so we account for those here as well. We only need the dates that those cycles started, because they ended when the current cycles started.

Tags
since
2.3.0

cb_core_set_spot_bonus_global()

Sets the amount for spot bonuses in our core class for easy access.

cb_core_set_spot_bonus_global() : mixed

Make sure to set this value in the DB via admin settings, or else we may never experience the bliss of automation.

Tags
since
3.0.0

cb_core_auto_reset()

Automatically increments the reset date by 1 year.

cb_core_auto_reset() : mixed
Tags
returns

DateTimeImmutable The DateTimeImmutable object, with the new reset date already locked and loaded.

since
3.0.0

cb_core_current_date()

CB Core Current Date

cb_core_current_date([bool $offset = false ][, string $format = "Y-m-d H:i:s" ]) : string

Returns the current date and time in the given format. Defaults to MySQL format in the site's timezone.

Parameters
$offset : bool = false

Whether to use the site's UTC offset setting. Default true.

$format : string = "Y-m-d H:i:s"

The desired datetime format. Default MySQL - 'Y-m-d H:i:s'

Tags
since
2.3.0
Return values
string

The formatted datetime.

str_starts_with()

Str Starts With

str_starts_with([string $haystack = '' ][, string $needle = '' ]) : bool

PHP 8 Polyfill for str_starts_with

Parameters
$haystack : string = ''

The string to search.

$needle : string = ''

The substring to search for at the beginning.

Tags
since
2.3.0
Return values
bool

Whether the string starts with the given substring.

str_ends_with()

Str Ends With

str_ends_with(string $haystack, string $needle) : bool

PHP 8 Polyfill for str_ends_with

Parameters
$haystack : string

The string to search.

$needle : string

The substring to search for at the end.

Tags
since
2.3.0
Return values
bool

Whether the string ends with the given substring.

str_contains()

Str Contains

str_contains(string $haystack, string $needle) : bool

PHP 8 Polyfill for str_contains

Parameters
$haystack : string

The string to search.

$needle : string

The substring to search for.

Tags
since
2.3.0
Return values
bool

Whether the string contains the given substring.

cb_flush_rewrite_rules()

CB Flush Rewrite Rules

cb_flush_rewrite_rules() : mixed

Flushes the rewrite rules after we update a plugin or theme, so our pages stop disappearing.

Tags
since
2.3.0

cb_get_patch_data()

Gets PATCH data from an HTTP PATCH request.

cb_get_patch_data() : array<string|int, mixed>

Retrieves data from a PATCH request and returns it as an associative array.

Tags
since
2.3.0
Return values
array<string|int, mixed>

The PATCH request body as an associative array.

cb_get_delete_data()

Gets DELETE data from an HTTP DELETE request.

cb_get_delete_data() : array<string|int, mixed>

Retrieves data from a DELETE request and returns it as an associative array.

Tags
since
2.3.0
Return values
array<string|int, mixed>

The DELETE request body as an associative array.

cb_core_get_missing_users()

Gets a list of transactions for nonexistent users.

cb_core_get_missing_users() : array<string|int, mixed>

Get a list of users that are present in the confetti_bits_transactions table, but not in the wp_users table. Returns an array of transactions where the sender or recipient isn't on the platform anymore.

Tags
since
2.3.0
Return values
array<string|int, mixed>

An associative array of transaction data.

cb_core_get_user_display_name()

Gets the user display name.

cb_core_get_user_display_name([int $user_id = 0 ]) : string

Attempts to get a display_name for the given user_id. If that comes up empty, searches for the first_name. If that also comes up empty, searches for the nickname. If there's no display name to be found, it gives us a lovely bunch of abject nothingness.

Parameters
$user_id : int = 0

The ID for the user whose name we want. Default current user_id.

Tags
since
2.3.0
Return values
string

The display_name on success, empty on failure.

cb_core_get_user_email()

Returns the email address for the given user.

cb_core_get_user_email([int $user_id = 0 ]) : string
Parameters
$user_id : int = 0

The ID of the user. Default current user.

Tags
since
3.0.0
Return values
string

The user's email address, if one exists.

cb_core_is_multi_array()

Checks if the parameter is a multi-dimensional array.

cb_core_is_multi_array(array<string|int, mixed> $arr) : bool
Parameters
$arr : array<string|int, mixed>

The array to check.

Tags
since
1.3.0
Return values
bool

Whether the array is multi-dimensional.

cb_core_send_sitewide_notice()

Sends out a sitewide notice.

cb_core_send_sitewide_notice() : mixed

Use this to send out non-critical updates that are intended to be informative or nice to know, such as an upcoming or recent update, new feature, etc.

Tags
since
1.2.0

cb_core_get_doomsday_clock()

Returns the number of days remaining until the reset date.

cb_core_get_doomsday_clock() : int
Tags
since
3.0.0
Return values
int

The number of days remaining before the reset.

cb_core_sanitize_string()

Washes away the sins of bad actors.

cb_core_sanitize_string([string $input = '' ]) : string

Use this to aggressively scrub input strings. I doubt that there are going to be any elite hackers playing injecting nonsense into this app, but this is good practice for other kinds of sanitization that we might want to do later.

Parameters
$input : string = ''

An input string

Tags
since
3.0.0
Return values
string

A kinder, gentler string.

cb_core_smtp_init()

Injects our own config settings into PHPMailer.

cb_core_smtp_init(PHPMailer $phpmailer) : mixed
Parameters
$phpmailer : PHPMailer

A PHPMailer object.

Tags
since
3.0.0

cb_core_delete_user_data()

Deletes all Confetti Bits data associated with deleted user.

cb_core_delete_user_data(int $id, int $reassign, WP_User $user) : mixed
Parameters
$id : int

The ID of the user that's being deleted.

$reassign : int

An optional user ID to reassign items to.

$user : WP_User

The instance of WP_User associated with the deleted user.

Tags
since
3.0.0

cb_core_ordinal_suffix()

Adds an ordinal suffix to a given integer.

cb_core_ordinal_suffix(int|string $int) : string
Parameters
$int : int|string

An integer.

Tags
since
3.0.0
Return values
string

The same integer, but with a little spice.


        
On this page

Search results