Properties

$prefix

$prefix : string

Type

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

$comments

$comments : array<mixed,\WP_Comment>

The visible chat messages.

Type

array<mixed,\WP_Comment>

$alert

$alert : \WP_Buoy_Alert

The alert associatd with this chat room.

Type

\WP_Buoy_Alert

Methods

register()

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.

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|string  $lookup) 

Constructor.

Parameters

integer|string $lookup

getPostId()

getPostId() : integer

Gets the ID of the WordPress post.

Returns

integer

is_responder()

is_responder(integer  $user_id) : boolean

Whether or not a given user is a responder for this alert.

Parameters

integer $user_id

Returns

boolean

is_alerter()

is_alerter(integer  $user_id) : boolean

Whether or not a given user is the "owner" of the chat room.

Parameters

integer $user_id

Returns

boolean

get_title()

get_title() : string

Retrieves the title of the alert for this chat room.

Returns

string

list_comments()

list_comments(array  $args = array()) : string|void

Gets the comment HTML.

Parameters

array $args

Arguments to pass to wp_list_comments()

Returns

string|void

renderComment()

renderComment(\WP_Comment  $comment, array  $args, integer  $depth) : void

Renders an individual comment.

Parameters

\WP_Comment $comment
array $args
integer $depth

renderMetaRefresh()

renderMetaRefresh() : void

Outputs the <meta> tag for refreshing the chat room automatically.

filterBodyClass()

filterBodyClass(array<mixed,string>  $classes) : array<mixed,string>

Adds "do_form_reset" to the body class for new chat reloads.

Parameters

array<mixed,string> $classes

Returns

array<mixed,string>

filterCommentClass()

filterCommentClass(array<mixed,string>  $classes) : array<mixed,string>

Adds our own class to each comment "chat message" output.

Parameters

array<mixed,string> $classes

Returns

array<mixed,string>

filterCommentText()

filterCommentText(string  $comment_text) : string

Spruces up the comment text when displaying a comment.

Chat messages are stored as comments in the WordPress database so this filter takes the text (typically a single line) and adds some basic expected functionality like turning links to images into inline images, and parsing simple markdown.

Parameters

string $comment_text

Returns

string

render()

render() : void

Renders a chat room.

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

renderCommentMedia()

renderCommentMedia(string  $align, \WP_Comment  $comment, array  $args, integer  $depth) : void

Renders an individual comment's media element.

Parameters

string $align

Either left or right

\WP_Comment $comment
array $args
integer $depth

renderCommentBody()

renderCommentBody(\WP_Comment  $comment, array  $args, integer  $depth) : void

Renders an individual comment's body.

Parameters

\WP_Comment $comment
array $args
integer $depth

error_msg()

error_msg(string  $message) : string

Prepares an error message for logging.

Parameters

string $message

Returns

string