Properties

$prefix

$prefix : string

Type

string — String to prefix option names, settings, etc.

$wp_user

$wp_user : \WP_User

The WordPress user.

Type

\WP_User

$teams

$teams : array<mixed,integer>

The user's teams.

Type

array<mixed,integer>

Methods

register()

register() : void

Registers user-related WordPress hooks.

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.

registerL10n()

registerL10n() : void

Loads localization files from plugin's languages directory.

initialize()

initialize() : void

Loads plugin componentry and calls that component's register() method. Called at the WordPress `init` hook.

activate()

activate(boolean  $network_wide) : void

Method to run when the plugin is activated by a user in the WordPress Dashboard admin screen.

Parameters

boolean $network_wide

checkPrereqs()

checkPrereqs() : void

Checks system requirements and exits if they are not met.

This first checks to ensure minimum WordPress and PHP versions have been satisfied. If not, the plugin deactivates and exits.

install_plugin_dependency()

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.

Parameters

string $slug
string $version

rest_api_install_failure_notice()

rest_api_install_failure_notice() 

get_minimum_wordpress_version()

get_minimum_wordpress_version() : string

Returns the "Requires at least" value from plugin's readme.txt.

Returns

string

deactivate()

deactivate() : void

Method to run when the plugin is deactivated by a user in the WordPress Dashboard admin screen.

enqueueFrontEndScripts()

enqueueFrontEndScripts() : void

Enqueues globally relevant scripts and stylesheets.

addHelpTab()

addHelpTab() : void

Attaches on-screen help tabs to the WordPress built-in help.

Loads the appropriate document from the localized help folder and inserts it as a help tab on the current screen.

addHelpSidebar()

addHelpSidebar() : void

Appends appropriate sidebar content based on current screen.

renderWebAppManifest()

renderWebAppManifest() : void

Prints the Web App manifest file.

renderWebAppHTML()

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.

registerDashboardWidget()

registerDashboardWidget() : void

Register the Dashboard widget.

renderDashboardWidget()

renderDashboardWidget() : void

Renders the Buoy Dashboard widget.

__construct()

__construct(integer  $user_id) : \WP_Buoy_User

Constructor.

Parameters

integer $user_id

Throws

\Exception

if the provided $user_id does not reference a valid WP_User object.

Returns

\WP_Buoy_User

getByPhoneNumber()

getByPhoneNumber(string  $phone_number) : false|\WP_Buoy_User

Gets a Buoy User object from a given phone number.

Parameters

string $phone_number

Returns

false|\WP_Buoy_User

get_teams()

get_teams() : array<mixed,integer>

Gets the user's (published) teams.

Returns

array<mixed,integer>

get_default_teams()

get_default_teams() : array<mixed,integer>

Gets the user's default teams.

Returns

array<mixed,integer>

has_responder()

has_responder() : boolean

Checks whether or not the user has at least one responder.

A "responder" in this context is a "confirmed" team member. At least one responder is needed before the "Activate Alert" screen will be of any use, obviously. This looks for confirmed members on any of the user's teams and returns as soon as it can find one.

Returns

boolean

get_pronoun()

get_pronoun() : string

Alias of WP_Buoy_User::get_gender_pronoun_possessive()

Returns

string

get_gender_pronoun_possessive()

get_gender_pronoun_possessive() : string

Gets the possessive gender pronoun of a user.

Returns

string

get_crisis_message()

get_crisis_message() : string

Get a user's pre-defined crisis message, or a default message if empty.

Returns

string

get_sms_email()

get_sms_email() : string

Gets a user's email-to-SMS address based on their profile.

Returns

string

get_incident_response_info()

get_incident_response_info(integer  $alert_id) : array

Retrieves info about this user's last known state associated with an alert that they have responded to.

Parameters

integer $alert_id

Returns

array

get_phone_number()

get_phone_number() : string

Gets a user's phone number, without dashes or other symbols.

Returns

string

warnIfNoResponder()

warnIfNoResponder(\WP_Buoy_Team  $team) : boolean

Sends a warning to a user if they no longer have responders.

Parameters

\WP_Buoy_Team $team

The team that has been emptied.

Returns

boolean

renderProfile()

renderProfile(\WP_User  $profileuser) : void

Prints the HTML for the custom profile fields.

Parameters

\WP_User $profileuser

saveProfile()

saveProfile(integer  $user_id) : void

Saves profile field values to the database on profile update.

Parameters

integer $user_id

renderChooseTeamsPanelHtml()

renderChooseTeamsPanelHtml() : string

Returns the HTML for a Bootstrap Panel of the user's teams.

Returns

string

debug_log()

debug_log(string  $message) : void

Prints a message to the WordPress debug log if the plugin's "detailed debugging" setting is enabled.

By default, the WordPress debug log is wp-content/debug.log relative to the WordPress installation root (ABSPATH).

Parameters

string $message

error_msg()

error_msg(string  $message) : string

Prepares an error message for logging.

Parameters

string $message

Returns

string

sanitize_phone_number()

sanitize_phone_number(string  $phone_number) : string

Returns a sanitized phone number (no dashes or symbols).

Parameters

string $phone_number

Returns

string

get_option()

get_option(string  $name, mixed  $default = null) : mixed

Gets the value of a user option they have set.

Parameters

string $name
mixed $default

Returns

mixed