Properties

$_instance

$_instance : object

Plugin singleton

Type

object

$_version

$_version : string

Plugin version

Type

string

$_file

$_file : string

Plugin's file path

Type

string

$_dir

$_dir : string

Plugin directory

Type

string

$_assets_url

$_assets_url : string

Plugin assets web path

Type

string

$_assets_dir

$_assets_dir : string

Plugin assets file path

Type

string

$_languages_dir

$_languages_dir : string

Plugin languages path

Type

string

$_className

$_className

$_model

$_model

$_view

$_view

$_optionsPage

$_optionsPage

$_options

$_options

Methods

get_instance()

get_instance( $file,  $version) : \plugin

Gets a singleton of this plugin

Retrieves or creates the plugin singleton.

Parameters

$file
$version

Returns

\plugin —

singleton

enqueue_styles()

enqueue_styles() : void

Registers the plugin's styles with WordPress.

enqueue_admin_styles()

enqueue_admin_styles( $hook) : void

Registers the plugin's admin styles with WordPress.

Parameters

$hook

enqueue_scripts()

enqueue_scripts() : void

Registers the plugin's scripts with WordPress.

enqueue_admin_scripts()

enqueue_admin_scripts( $hook) : void

Registers the plugin's admin scripts with WordPress.

Parameters

$hook

is_script_debug()

is_script_debug() : boolean

Helper function on whether SCRIPT_DEBUG is set

Returns whether or not SCRIPT_DEBUG is set.

Returns

boolean

is_wordpress_debug()

is_wordpress_debug() : boolean

Helper function on whether WP_DEBUG is set

Returns whether or not WP_DEBUG is set.

Returns

boolean

init_i18n_textdomain()

init_i18n_textdomain() : void

Initializes the textdomain for the plugin

init_languages()

init_languages() : void

Initialize lanaguages

addRedactButton()

addRedactButton(array $buttons)

A callback function during the mce_buttons filter hook that will add our redact button name to the array of buttons in the text editor.

Parameters

array $buttons

An array of button IDs to be rendered in the text editor HTML.

addCustomMcePlugin()

addCustomMcePlugin(array $plugins)

A callback function during the mce_external_plugins filter hook that will assign our javascript to be executed by TinyMCE when it renders itself. Our javascript will add the redact button to the editor.

Parameters

array $plugins

A map of TinyMCE plugin names to their implementations in a javascript.

adminInit()

adminInit()

This function will execute on the admin_init action hook and will provide the current user with the redact button if the current user has the edit post and edit page capability. The redact button is added by supplying callbacks to the text editor filter hooks.

redactShortcode()

redactShortcode(array $attr, string $content)

Switches out the content that is in between the redact shortcode with underscores and spaces for users whom are not allowed to see the redacted text. Each "redact" shortcode will call this function when the posting is rendered by wp. We add underscores and spaces as placeholders for the words that would have been displayed and we surround the redaction with an HTML span tag so that we may apply the redacted style to it. The style is defined in the css/style.css file which is loaded during wp's action hook for wp_enqueue_scripts.

Parameters

array $attr

Any attributes provided in the shortcode, we look for 'allow'

string $content

The original text in between the shortcode

convertToRedactStrings()

convertToRedactStrings(array $arrMatches) : array

Accepts an array of strings and translates them into what should be used as the redacted text. This returns redacted versions of the content no matter what the permissions are.

Parameters

array $arrMatches

The array of strings that are content that matches redacted text.

Returns

array —

$arrRedacted The array of strings translated into what should be used as redacted text.

redact()

redact( $allowedCsv,  $who,  $when, string $content)

Returns the content if the current user is assigned a role that is allowed to read the content, otherwise return a string with the same number of characters as the content but contains only underscores and spaces.

Parameters

$allowedCsv
$who
$when
string $content

The content to redact or display.

redact_string_content()

redact_string_content( $strContent) : \$strResult

Accepts a string to have content redacted. It uses RedactorModel to query the database for matching redactions and based on permissions replaces the matching text with appropriate content.

Made to be used with the add_action or add_filter function in WordPress.

Parameters

$strContent

Returns

\$strResult —

The string with the content replaced based on permissions

redact_comment_content()

redact_comment_content( $strContent) : \$strResult

Accepts a string to have content redacted. It uses RedactorModel to query the database for matching redactions and based on permissions replaces the matching text with appropriate content.

Made to be used with the add_action or add_filter function in WordPress.

Parameters

$strContent

Returns

\$strResult —

The string with the content replaced based on permissions

redact_post_content()

redact_post_content( $strContent) : \$strResult

Accepts a string to have content redacted. It uses RedactorModel to query the database for matching redactions and based on permissions replaces the matching text with appropriate content.

Made to be used with the add_action or add_filter function in WordPress.

Parameters

$strContent

Returns

\$strResult —

The string with the content replaced based on permissions

__construct()

__construct( $file,  $version) : void

Create and initializes the plugin

The plugin is a singleton so the constructor remains private

Parameters

$file
$version

_createURLs()

_createURLs( $file) : void

Create and stores all of the paths that the plugin will use to access the world

Parameters

$file

__clone()

__clone() : void

Not allowed

The plugin is a singleton so don't allow cloning.

_getMatchingStringsAndPermissions()

_getMatchingStringsAndPermissions(array $dbMatchingRows, string $strContent) : array

Translates the raw rows of the database and string content into a redaction array of matching text and the permissions around the redaction. The array is in the form of array(matches[], permissions, redacted[], pattern) foreach matching row of the database.

Parameters

array $dbMatchingRows

Raw rows from the database

string $strContent

String content to match against.

Returns

array —

$arrResults An array of results in the form of array(matches[], permissions[] , redacted[]) foreach matching row of the database.

_dedupeMatches()

_dedupeMatches(array $arrMatches) : array

Iterates through the list of matches and removes duplicate matches altering the permissions of the unique match to be most restrictive of the removed duplicates.

Parameters

array $arrMatches

Returns

array