$prefix : string
Class for creating and delegating responses to alerts.
Alerts are posts that record some incident information such as the location and attached media recordings of what's going on.
$hash : string
The alert's public identifier.
$hash is a randomly generated lookup value that is used
instead of a WordPress post ID. This is because a post ID is a
sequential number, and would expose the Buoy to attack if a bad
(malicious) actor. Using a hash value instead of an integer in
this context makes it harder for attackrs to guess quantity and
frequency of alerts that this Buoy maintains.
register() : void
Registers the Buoy Alert post type and 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.
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
plugin. It will not work as-is for other plugins.
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|\WP_Post|string $lookup = null) : \WP_Buoy_Alert
Retrieves an alert post as a WP_Buoy_Alert object, or an empty,
new such object if no
$lookup value is provided with which to
search for a pre-existing alert.
Optional lookup value, WP_Post, ID, or hash.
load(string|integer $lookup) : \WP_Buoy_Alert
Get an alert from the WordPress database based on lookup value.
The lookup value.
If no alert could be found using
set(array $postarr = array()) : \WP_Buoy_Alert
Sets the WP_Post data for this alert.
add_responder(integer $user_id) : \WP_Buoy_Alert
Adds a responder to this alert.
set_responder_geo(integer $user_id, array<mixed,float> $geo) : \WP_Buoy_Alert
Saves new geolocation data (lat/lon pair) for a responder.
filterCommentsClauses(array<mixed,string> $clauses, \WP_Comment_Query $wp_comment_query) : array<mixed,string>
Omit comments used in Buoy Alert chats from comment queries.
Comments on Buoy Alerts (posts with the type
actually "chat room" messages. These should not show elsewhere
in the WordPress blog, such as in the "Recent comments" widget
or other areas where a "show all comments" kind of request is
See also issue #157.
redirectShortUrl(\WP $wp) : void
Redirects users arriving at Buoy via short url.
Detects an alert "short URL," which is an HTTP GET request with
a special querystring parameter that matches the first 8 chars
of an alert's hash value and, if matched, redirects to the full
URL of that particular alert's "review" screen, then
This occurrs during WordPress's
renderChatRoom(\WP_Buoy_Alert $alert, $curr_user)
Hookable action to print out the HTML for the given chat room system.
This function is called by the custom
buoy_chat_room action hook.
Plugin developers can replace the Buoy chat room by hooking their
own code to the action after removing the default action. This allows
plugin developers to develop their own plugins that use custom chat
room code for their own Buoys.
handleNewPostCommentChat(boolean $open, integer $post_id) : boolean
Hooks the new comment routine to allow a "comment" on Alerts.
This is used to intercept the
function early in its processing and allow only comments with
the required Buoy Alert "chat" nonces to go through.
getIncidentMediaList(integer $post_id) : string
Returns an HTML structure containing nested lists and list items referring to any media attached to the given post ID.
The post ID from which to fetch attached media.
HTML ready for insertion into an