Availability: >= 3.0

Type: Object Method

Description: Registers a new button.


$editor->registerButtonstring $idnamestring $tooltipstring $functionstring $url [, int $width [, int $height [, string $buttonStateHandler]]] );


A unique id to identify this button.

The tooltip to appear when the user mouses over the button. If you leave the tooltip as an empty value the editor will look in the $lang['editor'] array in the language pack for a key that matches the $idname value.

JavaScript function to be called when this button is pressed. This is equivalent to what you might place in an onclick attribute.

The URL of the image to be used for this button. You might find Parameter Placeholders useful here.

The width of the button. 22 is the default.

The height of the button. 22 is the default.

ID of the Button State Handler that should handle the selection state for this button.

Once a new button has been registered you can add it to the toolbar layout using addRegisteredButton


The following example registers a new button with the id of 'cite'. The new button has been given the button state handler id of 'citehandler'. When clicked the button will insert a cite tag. We have used the addJSButtonStateHandler method to register a handler for the new button that will display the button as latched when the selection is within a cite tag.

Note that we have used Parameter Placeholders to make life easier when setting the $function and $url parameters.

// register a new button:

// add the new button to the toolbar layout:

// register the handler for the new button:
$editor->addJSButtonStateHandler ('citehandler''function (editor,srcElement,cid,inTable,inA,range){
    var c = range.getContainerByTagName("CITE");
    if (c) {
        return "wproLatched";
    } else {
        return "wproReady";

See also:

registerMenuButton, registerSelect, registerSeparator, registerSpacer, registerTextButton, setButtonFunction