$prefix
$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.
The $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 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|\WP_Post|string $lookup = null) : \WP_Buoy_Alert
Constructor.
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.
integer|\WP_Post|string | $lookup | 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.
string|integer | $lookup | The lookup value. |
If no alert could be found using $lookup
.
set(array $postarr = array()) : \WP_Buoy_Alert
Sets the WP_Post data for this alert.
array | $postarr | Same as |
add_responder(integer $user_id) : \WP_Buoy_Alert
Adds a responder to this alert.
integer | $user_id |
set_responder_geo(integer $user_id, array<mixed,float> $geo) : \WP_Buoy_Alert
Saves new geolocation data (lat/lon pair) for a responder.
integer | $user_id | |
array<mixed,float> | $geo |
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 buoy_alert
) are
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
asked for.
See also issue #157.
array<mixed,string> | $clauses | |
\WP_Comment_Query | $wp_comment_query |
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 exit()
s.
This occurrs during WordPress's send_headers
hook.
\WP | $wp |
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.
\WP_Buoy_Alert | $alert | |
$curr_user |
handleNewPostCommentChat(boolean $open, integer $post_id) : boolean
Hooks the new comment routine to allow a "comment" on Alerts.
This is used to intercept the wp_handle_comment_submission()
function early in its processing and allow only comments with
the required Buoy Alert "chat" nonces to go through.
boolean | $open | |
integer | $post_id |
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.
integer | $post_id | The post ID from which to fetch attached media. |
HTML ready for insertion into an <ul>
element.