$_instance
$_instance : object
Plugin singleton
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.
array | $plugins | A map of TinyMCE plugin names to their implementations in a javascript. |
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.
array | $attr | Any attributes provided in the shortcode, we look for 'allow' |
string | $content | The original text in between the shortcode |
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.
array | $arrMatches | The array of strings that are content that matches redacted text. |
$arrRedacted The array of strings translated into what should be used as redacted text.
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.
$allowedCsv | ||
$who | ||
$when | ||
string | $content | The content to redact or display. |
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.
$strContent |
The string with the content replaced based on permissions
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.
$strContent |
The string with the content replaced based on permissions
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.
$strContent |
The string with the content replaced based on permissions
_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.
array | $dbMatchingRows | Raw rows from the database |
string | $strContent | String content to match against. |
$arrResults An array of results in the form of array(matches[], permissions[] , redacted[]) foreach matching row of the database.