CONFETTI_BITS_AJAX_SLUG
public
mixed
CONFETTI_BITS_AJAX_SLUG
= 'cb-ajax'
public
mixed
CONFETTI_BITS_AJAX_SLUG
= 'cb-ajax'
public
mixed
CONFETTI_BITS_EVENTS_SLUG
= 'events'
public
mixed
CONFETTI_BITS_PARTICIPATION_SLUG
= 'participation'
public
mixed
CONFETTI_BITS_REQUEST_ITEMS_SLUG
= 'request-items'
public
mixed
CONFETTI_BITS_REQUESTS_SLUG
= 'requests'
public
mixed
CONFETTI_BITS_TRANSACTIONS_SLUG
= 'transactions'
Accepts either a singular contest object or an array of contest objects and adds them to the database.
cb_ajax_new_contests() : mixed
Updates contest objects for a given event.
cb_ajax_update_contests() : mixed
I'm a goofy goober. I ended up making this a lot more dynamic so it can handle a lot of different user interactions.
Sit back and enjoy, friend.
It's important to note that we aren't necessarily always modifying a singular contest object within the database. Here's a breakdown of what's going on here:
Should be fairly straightforward, but I've been wrong so many times before. ~~We might just run everything through the new_contests endpoint~~ ~~We're almost definitely going to be running updates through the new_contests endpoint.~~
We are absolutely not running updates through the new_contests endpoint.
Deletes existing contest objects from the database.
cb_ajax_delete_contests() : mixed
Retrieves contest objects from the database.
cb_ajax_get_contests() : mixed
Typically used to retrieve a list of placements based on a given event_id.
Creates a new event object and saves it to the database.
cb_ajax_new_events() : mixed
Updates an existing event object and saves it to the database.
cb_ajax_update_events() : mixed
Deletes an existing event object from the database.
cb_ajax_delete_events() : mixed
Retrieves event objects from the database.
cb_ajax_get_events() : mixed
Retrieves a list of participants for a given event.
cb_ajax_get_event_participants() : mixed
Saves contest placements for a given event.
cb_ajax_new_contest() : mixed
cb_ajax_get_bda() : mixed
cb_ajax_new_bda() : mixed
cb_ajax_update_bda() : mixed
cb_ajax_delete_bda() : mixed
Dynamically registers a REST route.
cb_ajax_register_rest_route([string $component = '' ]) : mixed
The component to register a route for.
Adds a REST endpoint so we can send out updates to the team with each commit.
cb_setup_gh_commit_notifications() : mixed
cb_handle_gh_commits(WP_REST_Request $request) : mixed
Loads our AJAX component, so we can play nice with Javascript.
cb_setup_ajax() : mixed
Handles HTTP PATCH requests to update participation entries.
cb_ajax_update_participation() : mixed
Processes standard and bulk participation updates from an HTTP PATCH request.
CB Ajax New Participation
cb_ajax_new_participation() : mixed
We'll use this to process the new participation entries sent via ajax.
CB AJAX Get Participation
cb_ajax_get_participation() : mixed
Our REST API handler for the endpoint at "/wp-json/cb-ajax/v1/participation/get"
Adds 5 participation entries for testing purposes.
cb_participation_add_filler_data() : mixed
Handles HTTP PATCH request_items to update request_items entries.
cb_ajax_update_request_items() : mixed
Processes standard and bulk request_items updates from an HTTP PATCH request.
CB Ajax New Request Items
cb_ajax_new_request_items() : mixed
We'll use this to process the new request_items entries sent via ajax.
Deletes request items from the request items table.
cb_ajax_delete_request_items() : int
The number of rows affected, or false on failure.
CB AJAX Get Request_items
cb_ajax_get_request_items() : mixed
Our REST API handler for the endpoint at "/wp-json/cb-ajax/v1/request_items/get"
Adds 5 request_items entries for testing purposes.
cb_request_items_add_filler_data() : mixed
Handles HTTP PATCH requests to update requests entries.
cb_ajax_update_requests() : mixed
Processes standard and bulk requests updates from an HTTP PATCH request.
CB Ajax New Requests
cb_ajax_new_requests() : mixed
We'll use this to process the new requests entries sent via ajax.
CB AJAX Get Requests
cb_ajax_get_requests() : mixed
Our REST API handler for the endpoint at "/wp-json/cb-ajax/v1/requests/get"
Deletes requests from the requests table.
cb_ajax_delete_requests() : int
The number of rows affected, or false on failure.
cb_dev_func_add_spot_bonuses() : mixed
Creates a new spot bonus and saves it to the database.
cb_ajax_new_spot_bonuses() : mixed
Updates an existing spot bonus and saves it to the database.
cb_ajax_update_spot_bonuses() : mixed
Deletes an existing spot bonus from the database.
cb_ajax_delete_spot_bonuses() : mixed
Retrieves spot bonuses from the database.
cb_ajax_get_spot_bonuses() : mixed
CB AJAX Get Transactions
cb_ajax_get_transactions() : JSON
Gets transactions for a user based on the user_id passed in the $_GET array.
{ 'text': JSON (JSON encoded array of transactions, or error message), 'type': string (success or error) }
CB AJAX New Transactions
cb_ajax_new_transactions() : mixed
AJAX handler for creating transactions.
All parameters are passed via POST request.
The following parameters are required:
cb_ajax_update_volunteers() : mixed
cb_ajax_get_volunteers() : mixed
cb_ajax_delete_volunteers() : mixed
Creates a new spot bonus and saves it to the database.
cb_ajax_new_volunteers() : mixed
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.
cb_core_admin_components_settings() : mixed
cb_admin_components_options() : mixed
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.
Grants all capabilities to administrator users.
cb_core_add_admin_caps() : mixed
An alias for current_user_can()
cb_core_current_user_can([string $cap = '' ]) : bool
The capability to check for.
Whether the user has the capability.
Checks whether a user is an admin of the given component.
cb_core_is_component_admin([string $component = '' ]) : bool
The component to check for.
Whether the user is an admin for the component.
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.
Whether the current user is a cb_admin.
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.
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).
Whether a user has administrative privileges.
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.
Whether a user has administrative privileges.
Checks whether a user has the cb_admin capability.
cb_core_admin_is_user_admin([mixed $user_id = 0 ]) : bool
Whether a user has cb_admin privileges.
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.
Whether a user is a participation 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.
Whether a user is a requests 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.
Whether a user is a staffing 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.
Whether a user is an events admin.
Let Editors manage users, and run this only once.
editor_manage_users() : mixed
Version: 1.0.0
Remove privileged menus from the admin area.
get_rid_of_the_menus() : mixed
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'.
Does an entire song and dance to see if this is the component you want.
cb_is_current_component([string $component = '' ]) : bool
The component to check for.
True if it's one of ours, false in any other scenario.
Asks the wizard if we could have some porridge.
cb_is_confetti_bits_component() : bool
Whether we may have some porridge.
Checks whether there is a currently logged-in user.
cb_is_user() : mixed
Checks to see if we're in the land of wonder.
cb_is_user_confetti_bits() : bool
Whether we're in the land of wonder.
Gives us an array of all active components.
cb_core_get_active_components() : array<string|int, mixed>
Active components.
Fires the cb_admin_enqueue_scripts action, where plugins can enqueue admin scripts.
cb_admin_enqueue_scripts() : mixed
Fires the cb_loaded action, where plugins can load their files.
cb_loaded() : mixed
Fires the cb_init action, where plugins can initialize their components.
cb_init() : mixed
Fires the cb_customize_register action, where plugins can register their customizer settings.
cb_customize_register(WP_Customize_Manager $customizer) : mixed
Fires the cb_ready action, where plugins can do things after the CB plugin is ready.
cb_ready() : mixed
Fires the cb_setup_current_user action, where plugins can do things after the current user is setup.
cb_setup_current_user() : mixed
Fires the cb_setup_theme action, where plugins can modify what happens while the theme is being setup.
cb_setup_theme() : mixed
Fires the cb_after_setup_theme action, where plugins can do things after the theme is setup.
cb_after_setup_theme() : mixed
Fires the cb_enqueue_scripts action, where plugins can register their front-end scripts.
cb_enqueue_scripts() : mixed
Fires the cb_template_redirect action, where plugins can do things before the template is loaded.
cb_template_redirect() : mixed
Fires the cb_widgets_init action, where plugins can register their widgets.
cb_widgets_init() : mixed
Fires the cb_generate_rewrite_rules action, where plugins can add their rewrite rules.
cb_generate_rewrite_rules(mixed $wp_rewrite) : mixed
Fires the cb_setup_components action, where plugins can register their components.
cb_setup_components() : mixed
Fires the cb_include action, where plugins can include their files.
cb_include() : mixed
Fires the cb_register_post_types action, where plugins can register their post types.
cb_register_post_types() : mixed
Fires the cb_register_taxonomies action, where plugins can register their taxonomies.
cb_register_taxonomies() : mixed
Fires the cb_setup_globals action, where plugins can register their globals.
cb_setup_globals() : mixed
Fires the cb_setup_canonical_stack action, where plugins can register their canonical stack.
cb_setup_canonical_stack() : mixed
Fires the cb_setup_nav action, where plugins can register their nav items.
cb_setup_nav() : mixed
Fires the cb_setup_title action, where plugins can register their title.
cb_setup_title() : mixed
Fires the cb_add_rewrite_tags action, where plugins can add their rewrite tags.
cb_add_rewrite_tags() : mixed
Fires the cb_add_rewrite_rules action, where plugins can add their rewrite rules.
cb_add_rewrite_rules() : mixed
Fires the cb_add_permastructs action, where plugins can add their permastructs.
cb_add_permastructs() : mixed
Fires the cb_register_member_types action, where plugins can register their member types.
cb_register_member_types() : mixed
Fires the cb_actions action, where plugins can register their actions.
cb_actions() : mixed
Fires the cb_screens action, where plugins can register their screens.
cb_screens() : mixed
Fires the cb_late_include action, where plugins can add include files after the canonical stack has been established.
cb_late_include() : mixed
Fires the cb_post_request action, where plugins can register their post requests.
cb_post_request() : mixed
Fires the cb_get_request action, where plugins can register their get requests.
cb_get_request() : mixed
Fires the cb_head action, where plugins can register their head items.
cb_head() : mixed
Fires the cb_request action, where plugins can modify their queries.
cb_request([mixed $query_vars = array() ]) : mixed
Fires the cb_login_redirect action, where plugins can modify the login redirect.
cb_login_redirect([string $redirect_to = '' ][, string $redirect_to_raw = '' ][, WP_User|WP_Error $user = false ]) : mixed
The redirect destination URL.
The requested redirect destination URL passed as a parameter.
WP_User object if login was successful, WP_Error object otherwise.
Fires the cb_template_include action, where plugins can modify the template.
cb_template_include([string $template = '' ]) : mixed
The template to include.
Fires the cb_allowed_themes action, where plugins can modify the allowed themes.
cb_allowed_themes(array<string|int, mixed> $themes) : mixed
The allowed themes.
Fires the cb_rest_api_init action, so we (and others) can easily hook into our REST API.
cb_rest_api_init() : mixed
CB Core Install Events
cb_core_install_events() : mixed
Installs our events table on the database.
Installs our spot bonus table on the database.
cb_core_install_spot_bonuses() : mixed
CB Core Install Transactions
cb_core_install_transactions() : mixed
Installs our transactions table on the database.
CB Core Install Participation
cb_core_install_participation() : mixed
Installs our transactions table on the database.
CB Core Install Contests
cb_core_install_contests() : mixed
Installs our contests table on the database.
CB Core Install Request Items
cb_core_install_request_items() : mixed
Installs our request items table on the database.
CB Core Install Requests
cb_core_install_requests() : mixed
Installs our requests table on the database.
Put stuff here that you want to run before installation.
cb_core_prepare_install() : mixed
Installs all our tables on the database.
cb_core_install([mixed $active_components = array() ]) : mixed
Also flushes the WordPress cache and rewrite rules so that our pages still show up after plugins get updated.
Sets up our Core component, which loads all of our other components.
cb_setup_core() : mixed
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?
An RFC 4211 compliant universally unique identifier.
CB Core Set API Key
cb_core_set_api_key([array<string|int, mixed> $args = [] ]) : string
Sets the encryption key that we use to encrypt and decrypt our API key in the database.
{ Array of arguments.
@type string $Name Required. A name for the secret. We hang onto this and use it to pull the secret from our secrets manager.
@type string $Description Optional. A description for the secret. Nice to have if you want, but not entirely necessary.
@type string $SecretString Required. This is a secret! Handle with extreme care. Please.
}
Results of the createSecret method, or error message on failure.
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!
The API key. Use with caution, share with none.
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.
The stringified Model data, or error message on failure.
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.
The stringified Model data, or error message on failure.
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.
The safe name for our API key.
Whether the API key exists and is valid.
CB Member Locate Template Part
cb_member_locate_template_part([string $template = '' ]) : string
Attempts to locate the specified template in the TeamCTG Child Theme, located at '/cb-template-parts/cb-{$template}.php'.
The template to look for.
The template, if found.
CB Member Get Template Part
cb_member_get_template_part([mixed $template = '' ]) : An
Loads a template part based on the template that gets passed in.
array of the active templates.
Confetti Bits Get Active Templates
cb_get_active_templates() : An
Sets up the templates to show users based on permissions.
array of the active templates.
Renders the member template part appropriate for the current page.
cb_member_template_part() : mixed
Right now? We only have the one page. Oof.
Adds Confetti Captain badges to the user's member profile page as well as to the activity feed, if they are a Confetti Captain.
cb_core_add_confetti_captain_badges() : mixed
Adds our custom 'confetti-captain' class to the BuddyBoss user avatar so that we can add a cute little sparkler icon using JS.
cb_core_confetti_captain_class(mixed $class, mixed $item_id) : mixed
Adds a cute litte sparkler badge on the profile page of users who are designated as "Confetti Captains", which meand they are part of the Confetti Captains group.
cb_core_confetti_captain_profile_badge() : mixed
Saves a new event to the database.
cb_events_new_event([array<string|int, mixed> $args = [] ]) : mixed
{ An associative array of arguments. Accepts any parameters of a CB_Events_Event object. }
Sends out notifications when a new event is created.
cb_events_new_notifications([array<string|int, mixed> $data = [] ]) : mixed
{ An associative array of key => value pairs from a CB_Events_Event object.
@see CB_Events_Event::save()
}
CB Events Update Notifications
cb_events_update_notifications([mixed $data = [] ]) : mixed
Sends out an update notification when an event is updated.
CB Setup Events
cb_setup_events() : mixed
Loads our Events component to give us easy access to global values.
cb_events_format_notifications([mixed $component_action = '' ][, mixed $args = [] ]) : mixed
cb_events_notifications([mixed $args = [] ]) : mixed
Gets markup for the calendar header.
cb_events_get_calendar_header([string $class_prefix = '' ]) : string
The prefix to add to the calendar header.
The formatted header markup.
Outputs a calendar view of events.
cb_events_get_calendar_view() : string
The formatted markup.
Outputs the markup for the calendar view.
cb_events_calendar_view() : mixed
Gets the markup for the events list view.
cb_events_get_list_view([bool $is_admin = false ]) : mixed
Whether the table is for an admin.
Outputs the markup for the events list view.
cb_events_list_view([bool $is_admin = false ]) : mixed
Whether the table is for an admin.
Adds rewrite rules to the events component so we don't get a false 404 when we update plugins.
cb_events_rewrite_rules() : mixed
cb_events_add_query_vars(mixed $query_vars) : mixed
cb_events_template_include(mixed $template) : mixed
Returns markup for a create or update form, determined by the given string.
cb_events_get_form_module([bool $is_edit_form = false ]) : string
Whether the form is for editing event data.
The form markup.
Gets the markup for the new events form module.
cb_events_get_new_event_module() : mixed
Outputs the markup for the new events module.
cb_events_new_event_module() : mixed
Returns markup for the edit_event form module.
cb_events_get_edit_event_module() : mixed
Outputs markup for the edit_events module.
cb_events_edit_event_module() : mixed
Adds a table for spot bonuses to the transactions tab.
cb_events_admin_table_module() : mixed
CB Participation Create Participation
cb_participation_new_participation(array<string|int, mixed> $args) : mixed
Creates a new participation object and saves it to the database.
Associative array of arguments for saving. All arguments are optional except for media_filepath. { @type int $item_id For BuddyBoss Platform's Notifications API. Registers the primary data for the notification. We'll use the applicant_id for this. ---------- @TODO: We need to make sure this is correct.
@type int $secondary_item_id For BuddyBoss Platform's Notifications API.
Register's the receiver's profile avatar in the notification.
We'll use the admin_id for this.
----------
@TODO: We need to make sure this is correct.
@type int $applicant_id The user_id associated with the participation entry.
@type int $admin_id The user_id of the last admin that modified the entry.
@type string $date_created A mysql datetime entry for when the participation was registered.
@type string $date_modified A mysql datetime entry for when the participation was registered.
@type string $event_type The type of event being registered.
We typically use these event_types: {
"dress_up",
"food",
"holiday",
"activity",
"awareness",
"meeting",
"workshop",
"contest",
"other"
}
@type string $component_name For BuddyBoss Platform's Notifications API.
Helps the API know which notification group to use.
@type string $component_action For BuddyBoss Platform's Notifications API.
Helps the API know which notification format to use.
@type string $status The status of the participation entry.
Common statuses include "new", "approved", "denied", or "pending".
}
Confetti Bits Participation New Transaction
cb_participation_new_transaction([array<string|int, mixed> $args = [] ]) : int|string
Add or subtract Confetti Bits based on participation approval status. We're probably going to deprecate all over this bad boy as we continue to transition everything to async.
An array of parameters for us to work with. { @type int $transaction_id A transaction ID for us to check for. @type int $participation_id A participation ID for us to check for. @type int $admin_id An admin ID for us to check for. @type string $status The status of the participation entry. @type string $modified The date of the last modification for the participation entry. @type int $amount An amount to check for in the transaction. }
Transaction ID on success, error on failure.
CB Participation Get Amount
cb_participation_get_amount([int $participation_id = 0 ][, string $status = '' ][, string $override = 0 ]) : int
Attempt to extract a predetermined value from valid event types.
The participation entry to check against
The status that we are updating to.
An amount override, typically submitted via form submission or API request.
$amount The amount we extracted.
CB Participation Get Log Entry
cb_participation_get_log_entry([int $participation_id = 0 ][, string $admin_log_entry = '' ]) : string
Attempt to extract a predetermined log entry from valid event types.
The ID for the participation entry we're checking.
An optional admin log entry override.
$log_entry The log entry we extracted.
CB Get Transaction
cb_participation_get_transaction([int $transaction_id = 0 ]) : array<string|int, mixed>|bool
We need to check if a transaction exists for a given participation entry, and perform operations based on that result.
The ID for the transaction we're looking for.
Transaction if the object exists, false if not or we get an error.
cb_participation_new_notifications([mixed $data = array() ]) : mixed
CB Participation Update Notifications
cb_participation_update_notifications([mixed $participation_id = 0 ]) : mixed
This will notify a user after a participation entry has been updated to a new status.
CB Setup Participation
cb_setup_participation() : mixed
Sets up our participation component, so we have easy access to component globals.
cb_participation_format_notifications([mixed $component_action = '' ][, mixed $args = [] ]) : mixed
CB Participation Event Type Filter
cb_participation_event_type_filter([bool $is_admin = false ]) : mixed
Outputs markup for a participation event type select input.
Whether it's for an filter selection. There's probably a better way to do this, but we need a band-aid for now, because we're down to the wire on this update. :D
Outputs markup for the participation nav.
cb_participation_nav() : mixed
Formats the nav data for the participation component.
cb_participation_format_nav_data([mixed $component = '' ][, array<string|int, mixed> $items = array() ]) : array<string|int, mixed>
We need a pretty complicated set of arguments for cb_templates_get_nav() and cb_templates_get_nav_items() and this helps us achieve that in a structured way.
A collection of key => value pairs
The list of formatted nav data.
Returns the nav for the participation filtering system.
cb_participation_get_nav() : string
The nav markup.
Outputs the participation admin nav.
cb_participation_admin_nav() : mixed
Returns the nav for the participation admin filtering system.
cb_participation_admin_get_nav() : string
The nav markup.
CB Requests Create Requests
cb_requests_new_request(array<string|int, mixed> $args) : mixed
Creates a new requests object and saves it to the database.
Associative array of arguments for saving. All arguments are optional except for media_filepath. { @type int $item_id For BuddyBoss Platform's Notifications API. Registers the primary data for the notification. We'll use the applicant_id for this.
@type int $secondary_item_id For BuddyBoss Platform's Notifications API.
Register's the receiver's profile avatar in the notification.
We'll use the admin_id for this.
@type int $applicant_id The user_id associated with the requests entry.
@type int $admin_id The user_id of the last admin that modified the entry.
@type string $date_created A mysql datetime entry for when the requests was registered.
@type string $date_modified A mysql datetime entry for when the requests was registered.
@type string $component_name For BuddyBoss Platform's Notifications API.
Helps the API know which notification group to use.
@type string $component_action For BuddyBoss Platform's Notifications API.
Helps the API know which notification format to use.
@type string $status The status of the requests entry.
Common statuses include "new", "approved", "denied", or "pending".
@type int $request_item_id The ID of the item being requested.
}
CB Requests New Transaction
cb_requests_new_transaction([array<string|int, mixed> $args = [] ]) : int|string
Add or subtract Confetti Bits based on request approval status.
An array of parameters for us to work with. { @type int $transaction_id A transaction ID for us to check for. @type int $request_id A requests ID for us to check for. @type int $admin_id An admin ID for us to check for. @type string $status The status of the requests entry. @type string $modified The date of the last modification for the requests entry. }
Transaction ID on success, error on failure.
Attempts to extract a predetermined value from a request item.
cb_requests_get_amount([int $request_item_id = 0 ]) : int
The ID of the request item with the request.
The amount we extracted.
Gets the name of a request item.
cb_requests_get_item_name([int $request_item_id = 0 ]) : string
The ID for the request item we're checking.
The item name we extracted.
Lists all available request items.
cb_requests_get_request_items([array<string|int, mixed> $args = [] ]) : array<string|int, mixed>
There's a built-in limit of 15 items, but that can be overridden in the arguments.
{ An optional array of arguments.
@type string|array $select A comma-separated list or
array of columns to get.
@type int $page The page of request items.
@type int $per_page How many request items should
appear on each page.
}
A 2D array of request items, structured like so: { [ [ 'id' => 1, 'item_name' => 'Item 1' ], [ 'id' => 2, 'item_name' => 'Item 2' ], ] }
Gets a transaction object, if any are associated with a request.
cb_requests_get_transaction([int $transaction_id = 0 ]) : array<string|int, mixed>|bool
Use this to check if a transaction already exists for a given request.
The ID for the transaction we're looking for.
Transaction if the object exists, false if not or we get an error.
Gets an array of requests from the database.
cb_requests_get_requests([array<string|int, mixed> $args = [] ]) : mixed
{ An associative array of arguments. @see CB_Requests_Request::get_requests() }
Returns the total amount of points the user has in open requests.
cb_requests_get_active_request_total([int $user_id = 0 ]) : int
The ID of the user to check.
The total amount of points that the user has in open requests.
Checks to see if a user can request the given item.
cb_requests_can_request([mixed $applicant_id = 0 ][, int $item_id = 0 ]) : bool
The ID of the item they want
True if they have enough to get the item, false otherwise.
Checks to see if a user can update their request item.
cb_requests_can_update([int $applicant_id = 0 ][, int $prev_item_id = 0 ][, int $updated_item_id = 0 ]) : bool
It basically subtracts the existing item from the active request total, adds on the cost of the new item, and checks to see if the items cost more than they have to spend on requests.
The ID of the user to check.
The ID of the previous item.
The ID of the new item that they would like to change to.
Whether the item would put the user over their request balance.
Sends a notification email when a request comes in.
cb_requests_new_notifications([mixed $data = [] ]) : mixed
CB Setup Requests
cb_setup_requests() : mixed
Sets up our requests component, so we have easy access to component globals.
CB Bits Request Sender Email Notification
cb_bits_request_sender_email_notification([array<string|int, mixed> $args = array() ]) : mixed
This function sends an email notification to the request sender
The arguments for the email notification.
Sends out notifications whenever someone submits a new request.
cb_requests_new_request_notifications([array<string|int, mixed> $args = [] ]) : mixed
{ An associative array of arguments passed from the CB_Requests_Request::save() method.
@see CB_Requests_Request::save()
}
Sends notifications to request admins after a new request is sent in.
cb_requests_admin_new_request_notifications([array<string|int, mixed> $args = [] ]) : mixed
{ An associative array of arguments passed from the CB_Requests_Request::save() method.
@see CB_Requests_Request::save()
}
Sends notifications to leadership after a new request is sent in.
cb_requests_leadership_new_request_notifications([array<string|int, mixed> $args = [] ]) : mixed
{ An associative array of arguments passed from the CB_Requests_Request::save() method.
@see CB_Requests_Request::save()
}
Sends notifications to site admins after a new request is sent in.
cb_requests_site_admins_new_request_notifications([array<string|int, mixed> $args = [] ]) : mixed
{ An associative array of arguments passed from the CB_Requests_Request::save() method.
@see CB_Requests_Request::save()
}
Notifies a user when their request status is updated.
cb_requests_update_request_notifications([mixed $update_args = [] ]) : mixed
cb_requests_format_notifications([mixed $component_action = '' ][, mixed $args = [] ]) : mixed
CB Requests Nav
cb_requests_nav() : mixed
Outputs the requests nav.
CB Requests Format Nav Data
cb_requests_format_nav_data([mixed $component = '' ][, array<string|int, mixed> $items = array() ]) : array<string|int, mixed>
Formats the nav data for the requests component. We need a pretty complicated set of arguments for cb_templates_get_nav() and cb_templates_get_nav_items() and this helps us achieve that in a structured way.
A collection of key => value pairs
The list of formatted nav data.
CB Requests Get Nav
cb_requests_get_nav() : string
Returns the nav for the requests filtering system.
The nav markup.
CB Requests Admin Nav
cb_requests_admin_nav() : mixed
Outputs the requests admin nav.
CB Requests Admin Get Nav
cb_requests_admin_get_nav() : string
Returns the nav for the requests admin filtering system.
The nav markup.
Gets markup for the request items form.
cb_requests_get_request_items_form() : string
The formatted markup.
Outputs markup for request items form.
cb_request_items_form() : mixed
Gets markup for the request items form.
cb_requests_get_requests_form() : string
The formatted markup.
Outputs markup for request items form.
cb_requests_form() : mixed
CB Templates Get Text Input
cb_templates_get_text_input([array<string|int, mixed> $args = [] ]) : mixed
Formats a text input that plays nice with our scripts.
A list of arguments {
CB Text Input
cb_text_input([array<string|int, mixed> $args = [] ]) : mixed
Outputs the text input.
The array of arguments that get passed to the getter. It would be wise to check what all is needed.
CB Templates Get Select Input
cb_templates_get_select_input([array<string|int, mixed> $args = array() ]) : mixed
Creates a select input element.
Accepts a bunch of optional arguments.
CB Templates Get Select Options
cb_templates_get_select_options([array<string|int, mixed> $args = [] ]) : mixed
Takes care of some of the business for making select inputs.
Arguments for the select input, listed below. Required. @type string $name The name of the option. Required. @type array $options The input values, and whether they are disabled or selected. @type string $value The value for the option. Required. @type bool $disabled Whether the option is disabled or not. Optional. @type bool $selected Whether the option is selected by default. Optional.
Confetti Bits Select Input
cb_select_input([array<string|int, mixed> $args = [] ]) : mixed
Outputs the select input.
The array of arguments that get passed to the getter. It would be wise to check what all is needed.
CB Templates Get Number Input
cb_templates_get_number_input([array<string|int, mixed> $args = [] ]) : mixed
Use this to create a number input element.
An array of arguments for the input element. Details below. All settings are optional.
CB Number Input
cb_number_input([array<string|int, mixed> $args = [] ]) : mixed
Outputs the number input.
The array of arguments that get passed to the getter. It would be wise to check what all is needed.
Confetti Bits Get File Input.
cb_templates_get_file_input([array<string|int, mixed> $args = [] ]) : mixed
Creates a file input element that accepts the specified filetypes.
An array of arguments for the input element. All optional.
@type string $label The label for the input. Default 'Upload a File'. @type string $class Custom class attribute for file input. @type string $name The value used in the for attribute of the label and the name and id attributes of the input. Default 'cb_file_upload'. @type bool $required Whether or not the field is required. Default false. @type bool $multiple Whether or not the field allows multiple files. Default false. @type bool $capture Whether or not the field allows the use of a camera. Default false. @type bool $disabled Whether or not the field is disabled. Default false. @type array $accepts An array of filetypes that the input accepts. Accepts either MIME type structures or filetype structures. Should be compliant with your Wordpress configuration. Default empty.
Confetti Bits File Input
cb_file_input([array<string|int, mixed> $args = [] ]) : mixed
Outputs the file input.
The array of arguments that get passed to the getter. It would be wise to check what all is needed.
CB Templates Get Submit Input.
cb_templates_get_submit_input([array<string|int, mixed> $args = [] ]) : mixed
Creates a submit input element that submits a form.
An array of arguments for the input element. All optional.
@type string $id The value used in the id attribute of the input. Default empty. @type value $value Value for the submit input. Default "Submit". @type bool $disabled Whether or not the field is disabled. Default false.
CB Submit Input
cb_submit_input([array<string|int, mixed> $args = [] ]) : mixed
Outputs the submit input markup.
The array of arguments that get passed to the getter. It would be wise to check what all is needed.
CB Templates Get Hidden Input
cb_templates_get_hidden_input([array<string|int, mixed> $args = [] ]) : mixed
Creates a hidden input that's either ready to receive a value or has a preset value.
Suggested utilities are getting things like user ids, logged-in usernames, emails, or empty inputs that get calculated on the page via javascript. We probably haven't written things like that yet, so you may have to set it up for your needs.
An array of arguments for the input. Name, id, value, disabled, multiple.
CB Hidden Input
cb_hidden_input([array<string|int, mixed> $args = [] ]) : mixed
Outputs the hidden input markup.
The array of arguments that get passed to the getter. It would be wise to check what all is needed.
CB Templates Get Checkbox Input
cb_templates_get_checkbox_input([array<string|int, mixed> $args = [] ]) : mixed
Creates a checkbox input with a label and as many options as you want.
An array of options for each input you want to include, structured in a 2D array of option names => array of option parameters. {
@type string $name The value used in the for, name, and id attributes.
@type string $label The label for the option.
@type string $value The value of the option.
@type bool $checked Whether the field is checked or not.
@type bool $disabled Whether the field is disabled or not.
}
CB Checkbox Input
cb_checkbox_input([array<string|int, mixed> $args = [] ]) : mixed
Outputs the checkbox input markup.
The array of arguments that get passed to the getter. It would be wise to check what all is needed.
CB Format Dropzone Input
cb_templates_get_dropzone_input([array<string|int, mixed> $args = [] ]) : mixed
Creates a hidden input and a container that can be used for drag-and-drop file uploads.
An array of arguments for the input. Name, id, value, disabled, multiple, etc.
CB Dropzone Input
cb_dropzone_input([array<string|int, mixed> $args = [] ]) : mixed
Outputs the hidden input markup.
The array of arguments that get passed to the getter. It would be wise to check what all is needed.
Alias for cb_templates_get_toggle_switch_input().
cb_templates_get_toggle_switch([mixed $args = [] ]) : mixed
Gets markup for a toggle switch input.
cb_templates_get_toggle_switch_input([array<string|int, mixed> $args = [] ]) : string
{ An array of options for each input you want to include, structured in a 2D array of options.
@type string $name The value used in the for, name, and id attributes.
@type string $label The label for the option.
@type string $value The value of the option.
@type bool $checked Whether the field is checked or not.
@type bool $disabled Whether the field is disabled or not.
}
The formatted markup.
CB Toggle Switch
cb_toggle_switch([array<string|int, mixed> $args = [] ]) : mixed
Outputs toggle switch markup.
An array of options for each input you want to include, structured in a 2D array of options.
@type string $name The value used in the for, name, and id attributes. @type string $label The label for the option. @type string $value The value of the option. @type bool $checked Whether the field is checked or not. @type bool $disabled Whether the field is disabled or not.
CB Templates Get Form
cb_templates_get_form([mixed $args = array() ]) : string
Gets the markup for a form element.
The formatted markup.
Outputs the markup for a form element.
cb_form([mixed $args = [] ]) : mixed
Gets the markup for a form module.
cb_templates_get_form_module([array<string|int, mixed> $args = [] ]) : string
Use this when you want the whole UI kit and caboodle on the Confetti Bits dashboard (i.e., you just want a form inside of a module).
{ An array of arguments.
@type string $component The name of the component.
@type string $method The form method.
@type array $classes Classes for the form element.
@type string $action The URL for the form handler.
@type string $output The markup that goes into the form.
@type string $enctype The encoding for the form.
@type string $autocomplete Whether the form should include
autocomplete features.
}
The formatted markup of the form module.
Returns formatted markup for a form button. Note that this should not be used as a submit button; we typically use input[type=submit] for that functionality. Here we'll default to button[type=button] to ensure that we can have it do what we want and not make the app have a heart attack.
cb_templates_get_form_button([array<string|int, mixed> $args = [] ]) : string
{ An associative array of arguments. Accepts various attributes of button elements, with support for your own custom attributes as well. }
The formatted markup.
Outputs the form module's markup.
cb_form_module([array<string|int, mixed> $args = [] ]) : mixed
{ @see cb_templates_get_form_module() }
Dynamically populates markup and input elements for a form.
cb_templates_get_form_output([array<string|int, mixed> $args = [] ]) : mixed
When given a heading, a component, and input arguments, this function can generate an entirely unique set of markup to put into a form element. It naturally prepends the "cb_" prefix to the beginning to stick within our namespace, then supplies the value supplied by the 'component' argument, and finally appends the value defined in the input_args['name'] argument to create a (hopefully) entirely unique input element, with the given type supplied in the input_args['type'] argument. Argument... Argument... Argument. Doesn't sound like a word anymore.
{ An array of - you guessed it - arguments.
@type string $component The name for the component. Used
to generate unique name and id
attributes in the input elements.
@type string $heading The heading to use in the output.
Basically for flavor.
}
A recursive helper function to help us process complex content trees.
cb_templates_recursive_helper([mixed $node = [] ]) : string
It'll recurse through each node that's labeled as a 'new_node' and return a string of content that's ready to echo out into the world.
The glorious content.
Gets markup for a time picker.
cb_templates_get_time_picker_input([array<string|int, mixed> $args = [] ]) : string
{ An associative array of arguments for the time picker.
@type string $name The name attribute for the input.
@type string $label The label for the input.
@type string $classes The classes for the input. @type string $value The value for the input. @type string $placeholder The placeholder for the input. @type string $min The minimum time for the input. @type string $max The maximum time for the input. @type string $step The step for the input.
}
The markup for the time picker input.
Outputs markup for a time picker.
cb_time_picker_input([mixed $args = [] ]) : mixed
Gets markup for a date picker input.
cb_templates_get_date_picker_input([array<string|int, mixed> $args = [] ]) : string
{ An associative array of arguments for the inputs.
@type string $label A label for the input.
@type string $name The name attribute for the input. Required.
@type string $placeholder A placeholder date string.
Default current date, formatted 'm/d/Y'.
@type string $value A preset value for the input.
@type bool $disabled Whether the input should be disabled by default.
Default false.
@type bool $hidden Whether the input should be hidden by default.
Default false.
@type bool $required Whether the input should be required by default.
Default false.
@type string|array $classes An array of classes that will be added
to the container element.
Default ['cb-date-picker'].
}
The formatted markup for the inputs.
Gets markup for both date and time inputs on one line.
cb_templates_get_datetime_picker_input([array<string|int, mixed> $args = [] ]) : string
{ An associative array of arguments for the inputs.
@type array $date {
@see cb_templates_get_date_picker_input()
}
@type array $time {
@see cb_templates_get_time_picker_input()
}
}
The formatted markup for the inputs.
Outputs markup for a datetime picker input.
cb_datetime_picker([mixed $args = [] ]) : mixed
Formats markup for a datetime-local input.
cb_templates_get_datetime_local_input([array<string|int, mixed> $args = [] ]) : string
I cannot believe I didn't know this existed until so recently.
{ An associative array of arguments.
@type string $label A label for the input.
@type string $name A name for the input.
@type string $placeholder A placeholder for the input.
@type string $value A default value for the input.
@type bool $disabled Whether the input is disabled by default.
@type bool $hidden Whether the input is hidden by default.
@type bool $required Whether the input is required by default.
@type array $classes An array of class selectors to give the input.
}
The formatted markup.
Outputs markup for a datetime-local input.
cb_datetime_local_input([mixed $args = [] ]) : mixed
Outputs markup for an actually nice date input. Uses Bootstrap styling and plugs in some custom data based on arguments passed.
cb_templates_get_date_input([array<string|int, mixed> $args = [] ]) : mixed
{ An optional array of arguments. }
Outputs markup for a pretty date input.
cb_date_input([mixed $args = [] ]) : mixed
cb_templates_get_time_selector_input([mixed $args = [] ]) : mixed
cb_time_selector_input([mixed $args = [] ]) : mixed
CB Templates Container
cb_templates_container([array<string|int, mixed> $args = array() ]) : string
A function that lets us wrap content dynamically with the supplied arguments, so we can have more fun and less pain.
An associative array of the following: { @var string $container The HTML tag to use for the container. Default 'div'. @var string $container_id The ID to use for the container. Default empty. @var array $container_classes An array of classes to use for the container. Default empty. @var string $output The content to wrap in the container. Default empty. }
The HTML markup to output.
Formats a button element with the given arguments
cb_templates_get_button([array<string|int, mixed> $args = array() ]) : string
{ @var string $id The ID of the button @var string $content The content of the button @var string $type The type of the button (button, reset, submit). Default 'button' @var array $classes An array of classes to add to the button. Default array('cb-button') }
The formatted button element
Formats a list item element with the given arguments
cb_templates_get_list_item([array<string|int, mixed> $args = array() ]) : string
{ @var string $id The ID of the item @var string $content The content of the item @var array $classes An array of classes to add to the button. Default array('cb-button') }
The formatted button element
CB Templates Get Link
cb_templates_get_link([array<string|int, mixed> $args = array() ]) : string
Returns a formatted anchor tag.
An array of options. { @type array $classes An array of classes to add to the element. @type string $href The href for the element. Default '#'. @type string $id The id for the element. @type string $content The text content of the element. @type array $custom_attr An array of custom data attributes for the element. }
The formatted anchor markup.
cb_templates_get_table([mixed $component = '' ][, mixed $heading = '' ][, mixed $paginated = true ]) : mixed
CB Templates AJAX Table
cb_templates_get_ajax_table([mixed $component = '' ][, mixed $heading = '' ][, mixed $paginated = true ]) : string|void
Returns a table for the specified component. Typically used for displaying items from the database that are fetched via AJAX. Optionally, a pagination bar can be displayed above and below the table.
The HTML for the table or nothing if the component is empty.
Outputs markup for an AJAX table.
cb_templates_ajax_table([string $component = '' ][, string $heading = '' ][, bool $paginated = true ]) : mixed
The component that gets used in a pile of CSS selectors.
A heading to use for the module. Default empty.
Whether the table should be paginated.
CB Get Pagination
cb_templates_get_pagination([string $component = '' ]) : string|void
Returns a pagination bar for the specified component. Typically used when displaying items from the database that are fetched via AJAX.
The component to display the pagination bar for.
The HTML for the pagination bar or nothing if the component is empty.
Formats the markup for a heading element.
cb_templates_get_heading([string $content = '' ][, int $level = 4 ]) : string
The content for the heading element. Default empty.
The level for the heading element. Default 4.
the formatted heading.
CB Templates Heading
cb_templates_heading([string $content = '' ][, int $level = 4 ]) : mixed
Output the markup for a heading element.
The content for the heading element. Default empty.
The level for the heading element. Default 4.
CB Templates Get Nav Items
cb_templates_get_nav_items([string $component = '' ][, array<string|int, mixed> $items = array() ]) : string
Returns a list of dynamically populated nav items as a string.
The component whose nav we need to make.
A 2D array of items to put into the nav. { @type array $label The label that will be used in the markup acts as a key for the nav item options { @type bool $active Adds an "active" class onto the list item if true. @type array $custom_attr An optional array of key => value pairs. @type string $href An href for the anchor element that will go inside the list item. } }
The markup of all the collective nav items.
CB Templates Get Nav
cb_templates_get_nav([string $component = '' ][, array<string|int, mixed> $items = array() ]) : string
Returns a dynamically populated nav as a string.
The component whose nav we need to make.
A 2D array of items to put into the nav. { @type array $label The label that will be used in the markup acts as a key for the nav item options { @type bool $active Adds an "active" class onto the list item if true. @type array $custom_attr An optional array of key => value pairs. @type string $href An href for the anchor element that will go inside the list item. } }
The nav markup.
CB Transactions Get History for User
cb_transactions_get_history_for_user([mixed $user_id = 0 ][, mixed $export_type = '' ]) : mixed
Handles the logic behind getting the right data from the database.
CB CSV Send Headers
cb_csv_send_headers([mixed $file_name = '' ]) : mixed
Manually alters headers to allow for us to modify how a csv reaches an end user, and to ensure safe passage for our noble data wizards.
CB Generate CSV
cb_generate_csv([array<string|int, mixed> $user_transactions = array() ][, string $export_type = '' ]) : mixed
Responsible for generating csv files for users that request an export of their data.
A 2D array of transactions
The type of export the user requested.
CB Export
cb_export() : mixed
Checks to see if export parameters are set on a POST request, exports transactions from the database based on parameters.
CB Activity Bits
cb_activity_bits(string $content, int $user_id, int $activity_id) : mixed
This hooks onto the BP Activity Posted Update action to give someone Confetti Bits when they post an update.
The content of the activity post.
The id of the user associated with the activity post.
The id of the activity post.
CB Transactions Get Total Sent Today
cb_transactions_get_total_sent_today() : int
This function gets the total number of Confetti Bits that have been sent for the current day.
$total The total number of Confetti Bits sent for the current day.
CB Transactions Get Request Balance
cb_transactions_get_request_balance([int $user_id = 0 ]) : int
Get the balance available to a user for the current spending cycle. The request balance resets 1 month after users are done earning for the year.
So the balance that is returned is a calculation based on the following timeline:
The ID for the user whose balance we want.
The calculated balance available for requests.
CB Transactions Get Transfer Balance
cb_transactions_get_transfer_balance([int $user_id = 0 ]) : int
Get the balance available to a user for the current earning cycle.
The ID for the user whose balance we want.
The calculated balance available for transfers.
CB Transactions Check Activity Bits
cb_transactions_check_activity_bits([int $user_id = 0 ]) : mixed
Checks to see if there were any days throughout the cycle where the user might have posted on the BuddyBoss activity feed, and didn't receive any points for it. Helps cover our tail if we accidentally push some breaking changes or do something silly with how activity bits are registered.
The ID for the user we want to check.
CB Transactions Get Activity Posts
cb_transactions_get_activity_posts([int $user_id = 0 ]) : array<string|int, mixed>
Returns an array of activity posts for the given user. Uses BuddyBoss's global value for the activities table name.
The ID of the user whose posts we want.
An array of activity posts, if any.
CB Transactions Get Activity Transactions
cb_transactions_get_activity_transactions([int $user_id = 0 ]) : array<string|int, mixed>
Retrieves a list of all transactions from the current earning cycle that were registered by a user posting on the BuddyBoss activity feed.
The user's ID. Default current user ID.
An array of transactions, if there are any.
CB Transactions Calculate Activity Bits
cb_transactions_calculate_activity_bits([array<string|int, mixed> $activities = array() ][, array<string|int, mixed> $transactions = array() ]) : array<string|int, mixed>
Calculates how many points a user should receive according to the number of unaccounted for activity posts they've sent out, that don't have an accompanying Confetti Bits transaction on that same day.
An array of activity posts
An array of transactions
An array of activity posts that are missing an accompanying transaction on a given day.
CB Transactions Has Bits
cb_transactions_has_bits([string $action = '' ]) : bool
Checks whether the user has gotten Confetti Bits for a specific action this year.
The action to check the database for. Usually either "birthday" or "anniversary".
Whether we found an entry for the given action within the past year.
CB Transactions Birthday Bits
cb_transactions_birthday_bits() : mixed
Gives the user Confetti Bits on their birthday.
CB Transactions Anniversary Bits
cb_transactions_anniversary_bits() : mixed
Gives the user Confetti Bits on their anniversary.
CB Transactions Get Amount From Anniversary
cb_transactions_get_amount_from_anniversary(DateTime $date) : int
The transaction amount appropriate for the anniversary date
CB Transactions Get Leaderboard
cb_transactions_get_leaderboard([mixed $limit = true ][, mixed $previous = false ]) : array<string|int, mixed>
Queries the database for the top 15 users by Confetti Bits balance Also includes the current user if they aren't in the top 15
$results The top 15 users by Confetti Bits balance, or the top 15 users by Confetti Bits balance with the current user included
CB Transactions Delete Transaction
cb_transactions_delete_transaction([array<string|int, mixed> $args = [] ]) : int
Delete a transaction from the database. Do this at your own risk, you cannot undo this action.
{ An associative array of keys and values to check the database for. Accepts any property of a CB_Transactions_Transaction object. Example: ['recipient_id' => 5, 'component_action' => 'cb_activity_bits'] Passing the above will delete all transactions where the recipient_id is 5, and the component_action is cb_activity_bits. }
The number of rows affected. @see $wpdb::delete()
CB Transactions New Transaction
cb_transactions_new_transaction([array<string|int, mixed> $args = [] ]) : mixed
Manages sending bits between users. Yikes.
An array of arguments that get merged into a set of default values. {
@var int $item_id The item ID associated with the transaction. Used with BuddyBoss's Notifications API to help format some dynamic information in the notifications. We use the sender_id for this.
@var int $secondary_item_id The secondary item ID associated with the transaction. Used with BuddyBoss's Notifications API to help format some dynamic information in the notifications. We use the recipient_id for this.
@var int $sender_id The ID of the user sending the bits.
@var int $recipient_id The ID of the user recieving the bits.
@var datetime $date_sent The date and time of the transaction.
@var string $log_entry A note that usually references the purpose for the transaction.
@TODO: Make log entries optional?
@var string $component_name The name associated with the component that is sending the bits. Used with BuddyBoss's Notifications API. This will almost always just be 'confetti_bits'.
@var string $component_action The action associated with the transaction. We use this to differentiate transaction types to easily categorize them and run calculations. It is also used with BuddyBoss's Notifications API to send certain notifications that are associated with certain actions. }
CB Transactions Remove Bits
cb_transactions_remove_bits(mixed $id, mixed $reassign, mixed $user) : mixed
This is hooked into the delete_user action, so that transactions get deleted whenever a user is.
A supplemental helper function that will let us process event-based transactions without modifying existing API stuff too much.
cb_transactions_new_events_transaction([array<string|int, mixed> $args = [] ]) : int|bool|string
We'll likely add more robust error handling later on. It's just getting down to the wire and we gotta push this out ASAP.
{ An array of arguments. All required.
@type int $event_id The ID of the event object.
@type int $recipient_id The ID of the recipient user.
}
Transaction ID on full success, false if something is missing, an error message if something when wrong.
A supplemental helper function that will let us process contest-based transactions without modifying existing API stuff too much.
cb_transactions_new_contests_transaction([array<string|int, mixed> $args = [] ]) : int|bool|string
We'll likely add more robust error handling later on. It's just getting down to the wire and we gotta push this out ASAP.
{ An array of arguments. All required.
@type int $event_id The ID of the event object.
@type int $recipient_id The ID of the recipient user.
}
Transaction ID on full success, false if something is missing, an error message if something when wrong.
CB Import Bits
cb_import_bits([mixed $args = [] ]) : mixed
This is going to allow an admin user to bulk import Confetti Bits transactions from a CSV file.
Confetti Bits Importer
cb_importer() : mixed
This is going to allow an admin user to bulk import a whole list of Confetti Bits transactions using PHP's built-in csv parser. We've included a lot of sanitization and error-handling here, but it could always be improved upon.
Some explanatory comments throughout, but the gist is: Make sure it's a post request, on the confetti bits page, from the import panel Get the wp importer Set the redirect path so we can P-R-G after it's finished, Set some variables to display after the import Set where the files go Open the filestream Start the import process Read each line, validate each field Make sure nothing insane is going into our database Compile the feedback and shove it into a session token Redirect Get the messages, kick back and enjoy
CB Import BDA
cb_import_bda([mixed $args = '' ]) : mixed
This is going to allow an admin user to bulk import birthdays and anniversaries from a CSV file.
CB BDA Importer
cb_bda_importer() : mixed
This is going to allow an admin user to bulk import a whole list of birthdays and anniversaries using PHP's built-in csv parser.
Some explanatory comments throughout, but the gist is: Make sure it's a post request, on the confetti bits page, from the import panel Get the wp importer Set the redirect path so we can P-R-G after it's finished, Set some variables to display after the import Set where the files go Open the filestream Start the import process Read each line, validate each field Make sure nothing insane is going into our database Compile the feedback and shove it into a session token Redirect Get the messages, kick back and enjoy
CB Setup Transactions
cb_setup_transactions() : mixed
Sets up our transactions component, so we have easy access to component globals.
Sends a notification to members of a group when someone posts.
cb_groups_activity_notifications(string $content, int $user_id, int $group_id, int $activity_id) : mixed
The notification content.
The ID of the user who is posting in the group.
The group ID.
The ID of the activity post.
Sends transaction notifications based on component action.
cb_transactions_notifications([array<string|int, mixed> $data = [] ]) : int|bool
{ An associative array of data received from the CB_Transactions_Transaction::save() method.
@see CB_Transactions_Transaction::save().
}
Notification ID on success, false on failure.
cb_transactions_format_notifications([mixed $component_action = '' ][, mixed $args = [] ]) : mixed
cb_groups_format_notifications(mixed $component_action[, mixed $args = [] ]) : mixed
cb_transactions_spot_bonus_notifications([mixed $args = [] ]) : mixed
cb_transactions_volunteer_bits_notifications([mixed $args = [] ]) : mixed
Gets the total number of Confetti Bits that have been sent for the current day and returns a notice to the user.
cb_transactions_get_total_sent_today_notice() : string
$notice The notice to be displayed to the user.
Output the total number of Confetti Bits that the user has sent for the current day.
cb_transactions_total_sent_today_notice() : mixed
Display the users request balance.
cb_transactions_request_balance([int $user_id = 0 ]) : mixed
The user ID.
Get the users request balance notice.
cb_transactions_get_request_balance_notice([int $user_id = 0 ]) : string
The user ID.
The users request balance notice.
Output the users request balance notice.
cb_transactions_request_balance_notice() : mixed
CB Transactions Balances Notice
cb_transactions_get_balances_notice([int $user_id = 0 ]) : string
Assemble the markup for both the user's transfer balance and their request balance.
The id of the user whose balance notice we're assembling. Defaults to current logged-in user.
$notice the formatted notice markup.
CB Transactions Balances Notice
cb_transactions_balances_notice() : mixed
Display the users balances above the dashboard.
CB Transactions Get Transfer Balance Notice
cb_transactions_get_transfer_balance_notice([int $user_id = 0 ]) : string
Assemble the transfer balance markup for the user's transfer balance notice.
The id of the user whose balance notice we're assembling. Defaults to current logged-in user.
$notice the formatted notice markup.
Dynamically gets the markup for the balance notice at the top of the dashboard.
cb_transactions_get_balance_notice([string $type = '' ][, int $user_id = 0 ]) : string
The type of balance notice to return.
The ID for the user whose balance we're retrieving.
The markup for the balance notice.
Outputs a balance notice of the given type, for the given user.
cb_transactions_balance_notice([mixed $type = '' ][, mixed $user_id = 0 ]) : mixed
CB Transactions Transfer Balance Notice
cb_transactions_transfer_balance_notice() : mixed
Output markup that shows a user's transfer balance.
CB Transactions Get Request Selection
cb_transactions_get_request_selection() : string
Get markup for the Request Selection Input
The formatted select input.
Outputs markup for the request selector.
cb_transactions_request_selection() : mixed
Returns container markup with transactions leaderboard content inside.
cb_transactions_get_leaderboard_module() : string
The formatted markup
Outputs the markup for the Confetti Bits leaderboard module.
cb_transactions_leaderboard_module() : mixed
Gets the containerized markup for the send bits module on the Confetti Bits dashboard.
cb_transactions_get_send_bits_module() : string
The formatted markup.
Outputs the markup for the send bits module.
cb_transactions_send_bits_module() : mixed
Returns a string of markup that contains listings for the top 15 users with the most Confetti Bits.
cb_transactions_get_formatted_leaderboard() : string
The formatted markup.
Outputs markup for the transactions leaderboard.
cb_transactions_leaderboard() : mixed
Formats the markup for the "Import Birthdays" module.
cb_transactions_get_import_bda_module() : string
Uses a bunch of our new templating structure to clean up some of the excess markup lying around here.
The formatted markup.
Outputs the "Import B-Days & Anniversaries" markup.
cb_import_bda_module() : mixed
cb_transactions_get_spot_bonus_module() : mixed
cb_transactions_get_volunteers_module() : mixed
Adds a table for spot bonuses to the transactions tab.
cb_transactions_spot_bonus_table_module() : mixed
Adds the spot bonus form to the transactions tab.
cb_transactions_spot_bonus_module() : mixed
cb_transactions_volunteer_hours_module() : mixed
The main function responsible for returning the one true Confetti_Bits
Confetti_Bits() : Confetti_Bits
Display notice if BuddyBoss Platform is not installed.
cb_install_bb_platform_notice() : mixed
Display notice if BuddyBoss Platform is not updated.
cb_update_bb_platform_notice() : mixed
Check if Confetti Bits is active.
cb_bp_is_active() : mixed
Init the plugin.
cb_plugin_init() : void
CB Is Get Request
cb_is_get_request() : bool
Checks if the current request is a GET request
True if GET request, false otherwise
CB Is Post Request
cb_is_post_request() : bool
Checks if the current request is a POST request
True if POST request, false otherwise
CB Is Patch Request
cb_is_patch_request() : bool
Checks if the current request is a PATCH request
True if PATCH request, false otherwise
CB Is Delete Request
cb_is_delete_request() : bool
Checks if the current request is a DELETE request
True if DELETE request, false otherwise
confetti_bits_admin_enqueue_script() : mixed
Initializes our notifications class.
cb_core_notifications_init() : mixed
So we can get those sweet, sweet noties.
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
cb_save_user_birthday_anniversary_fields(mixed $user_id, mixed $notify) : mixed
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.
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.
Automatically increments the reset date by 1 year.
cb_core_auto_reset() : mixed
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.
Whether to use the site's UTC offset setting. Default true.
The desired datetime format. Default MySQL - 'Y-m-d H:i:s'
The formatted datetime.
Str Starts With
str_starts_with([string $haystack = '' ][, string $needle = '' ]) : bool
PHP 8 Polyfill for str_starts_with
The string to search.
The substring to search for at the beginning.
Whether the string starts with the given substring.
Str Ends With
str_ends_with(string $haystack, string $needle) : bool
PHP 8 Polyfill for str_ends_with
The string to search.
The substring to search for at the end.
Whether the string ends with the given substring.
Str Contains
str_contains(string $haystack, string $needle) : bool
PHP 8 Polyfill for str_contains
The string to search.
The substring to search for.
Whether the string contains the given substring.
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.
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.
The PATCH request body as an associative array.
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.
The DELETE request body as an associative array.
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.
An associative array of transaction data.
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.
The ID for the user whose name we want. Default current user_id.
The display_name on success, empty on failure.
Returns the email address for the given user.
cb_core_get_user_email([int $user_id = 0 ]) : string
The ID of the user. Default current user.
The user's email address, if one exists.
Checks if the parameter is a multi-dimensional array.
cb_core_is_multi_array(array<string|int, mixed> $arr) : bool
The array to check.
Whether the array is multi-dimensional.
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.
Returns the number of days remaining until the reset date.
cb_core_get_doomsday_clock() : int
The number of days remaining before the reset.
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.
An input string
A kinder, gentler string.
Injects our own config settings into PHPMailer.
cb_core_smtp_init(PHPMailer $phpmailer) : mixed
A PHPMailer object.
Adds a menu item for our settings.
cb_core_admin_menu() : mixed
Formats markup for our admin settings page.
cb_templates_get_admin_page() : string
The formatted page markup.
Outputs markup for our admin settings page.
cb_core_admin_page() : mixed
cb_core_admin_settings_init() : mixed
Will eventually be used to sanitize user input in the admin menu.
cb_core_admin_settings_sanitize(mixed $input) : string
The input passed via post.
$input The "sanitized" input.
Returns the content for our main settings section.
cb_core_admin_settings_section_callback() : string
Content.
Outputs the setting field for the reset date.
cb_core_admin_reset_date_setting() : mixed
Outputs the setting field for the volunteer amount per hour.
cb_core_admin_volunteer_setting() : mixed
Outputs the setting field for the volunteer amount per hour.
cb_core_admin_spot_bonus_setting() : mixed
Replaces our default script tags with modules.
cb_core_convert_scripts_to_modules(mixed $tag, mixed $handle, mixed $src) : mixed
Deletes all Confetti Bits data associated with deleted user.
cb_core_delete_user_data(int $id, int $reassign, WP_User $user) : mixed
The ID of the user that's being deleted.
An optional user ID to reassign items to.
The instance of WP_User associated with the deleted user.
cb_core_do_spot_bonuses() : mixed
cb_core_listify(mixed $string) : mixed
cb_core_schedule_events() : mixed
cb_core_utc_to_local([mixed $date_string = '' ]) : mixed
Adds an ordinal suffix to a given integer.
cb_core_ordinal_suffix(int|string $int) : string
An integer.
The same integer, but with a little spice.