$prefix
$prefix : string
Main class for a Buoy Team.
Teams are groups/lists of potential responders managed by one user who invites them to join said team. They are implemented as a WP custom post type.
register() : void
Entry point for the WordPress framework into plugin code.
This is the method called when WordPress loads the plugin file. It is responsible for "registering" the plugin's main functions with the WordPress Plugin API.
install_plugin_dependency(string $slug, string $version = '')
Automates installation of other plugins that we need.
We only use this for the WP REST API at the moment. It's the 1 and only dependency we have on other plugins. When that plugin gets added to WP Core, we can remove this code.
As a result, note that this code is SPECIFIC to the rest-api
plugin. It will not work as-is for other plugins.
string | $slug | |
string | $version |
renderWebAppHTML() : void
Prints meta tag indicators for native-like functionality.
The "activate alert" screen is intended to be the web app "install" screen for Buoy. We insert special mobile browser specific tags in order to create a native-like "installer" for the user. We only want to do this on this specific screen.
__construct(integer $team_id) : \WP_Buoy_Team
Constructor.
integer | $team_id | The post ID of the team. |
get_members_in_states(array $states = array()) : array<mixed,array>|\WP_Error
Gets team member IDs by state.
For the "invited" state, an ID is an email address.
array | $states | Defaults to |
2D array of state => IDs
set_default() : \WP_Buoy_Team
Makes this team part a default team of the author.
unset_default() : \WP_Buoy_Team
Removes this team from the list of default teams.
Refuses to remove the team from the list of default teams if the team's author does not have any other default teams. This ensures that a user always has at least one default team.
get_team_owner() : \WP_Buoy_User
Gets the Team's owner.
add_member(integer $user_id, boolean $notify = true) : \WP_Buoy_Team
Adds a user to this team (a new member).
integer | $user_id | |
boolean | $notify | Whether or not to trigger a notification when adding. |
remove_member(integer $user_id) : \WP_Buoy_Team
Removes a member from this team.
integer | $user_id |
confirm_member(integer $user_id) : \WP_Buoy_Team
Sets the confirmation flag for a user on this team.
integer | $user_id |
unconfirm_member(integer $user_id) : \WP_Buoy_Team
Unsets the confirmation flag for a user on this team.
integer | $user_id |
postUpdated(integer $post_id, \WP_Post $post_after, \WP_Post $post_before) : void
Checks to ensure a user doesn't leave themselves without any responders.
Teams are only "active" is they are in the "publish" status. This checks a team transition and if the action leaves a user without any responders, it will re-set the team's status.
integer | $post_id | |
\WP_Post | $post_after | |
\WP_Post | $post_before |
deletedPostMeta(array $meta_ids, integer $post_id, string $meta_key, mixed $meta_value) : void
Hooks the `deleted_post_meta` action.
This is used primarily to detect when a user is removed from a team and, when this occurrs, remove the confirmation flag, too.
array | $meta_ids | |
integer | $post_id | |
string | $meta_key | |
mixed | $meta_value |
checkMemberCount(integer $user_id, $team)
Checks if a team no longer has any members.
If a team is emptied for any reason, whether because the user has removed all their members or the members themselves decide to leave, this will fire a "{$post->post_type}_emptied" hook.
integer | $user_id | The user who was just removed. |
$team |
filterCaps(array $caps) : array
Dynamically configures user capabilities.
This dynamism prevents the need to write capabilities into the
database's options
table's wp_user_roles
record itself.
Currently simply unconditionally gives every user the required capabilities to manage their own crisis response teams.
Called by the user_has_cap
filter.
array | $caps | The user's actual capabilities. |
$caps